improves CLI import echo output
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Jun 2016 06:46:10 +0000 (08:46 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 21 Jun 2016 11:50:59 +0000 (13:50 +0200)
.... show updatecount and hide zero counts

Change-Id: I57621d26faaf82a949a69986abc0636425c040de
Reviewed-on: http://gerrit.tine20.com/customers/3240
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Admin/CliTest.php
tine20/Tinebase/Frontend/Cli/Abstract.php

index b07538a..4493cd3 100644 (file)
@@ -325,9 +325,9 @@ class Admin_CliTest extends TestCase
     {
         // check output
         if ($username == 'hmoster') {
-            $this->assertEquals("Imported 3 records. Import failed for 0 records. \n", $out);
+            $this->assertEquals("Imported 3 records.\n", $out);
         } else {
-            $this->assertEquals("Imported 1 records. Import failed for 2 records. \n", $out);
+            $this->assertEquals("Imported 1 records.\nImport failed for 2 records.\n", $out);
         }
         
         // check if users (with their data) have been added to tine20
@@ -459,7 +459,7 @@ class Admin_CliTest extends TestCase
         ob_start();
         $this->_cli->importGroups($opts);
         $out = ob_get_clean();
-        $this->assertStringStartsWith('Imported 0 records.', $out);
+        $this->assertTrue($out === '');
         
         $expected = array('men' => 3, 'women' => 2,  'lowperformers' => 2, 'highperformers' => 3);
         $this->_testImportGroupsHelper($expected);
index 3718b2f..b123a45 100644 (file)
@@ -388,12 +388,21 @@ class Tinebase_Frontend_Cli_Abstract
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $e->getTraceAsString());
                 continue;
             }
-            
-            echo "Imported " . $result[$filename]['totalcount'] . " records. Import failed for " . $result[$filename]['failcount'] . " records. \n";
+
+            // TODO use a loop here
+            if (isset($result[$filename]['totalcount']) && ! empty($result[$filename]['totalcount'])) {
+                echo "Imported " . $result[$filename]['totalcount'] . " records.\n";
+            }
+            if (isset($result[$filename]['failcount']) && ! empty($result[$filename]['failcount'])) {
+                echo "Import failed for " . $result[$filename]['failcount'] . " records.\n";
+            }
             if (isset($result[$filename]['duplicatecount']) && ! empty($result[$filename]['duplicatecount'])) {
                 echo "Found " . $result[$filename]['duplicatecount'] . " duplicates.\n";
             }
-            
+            if (isset($result[$filename]['updatecount']) && ! empty($result[$filename]['updatecount'])) {
+                echo "Updated " . $result[$filename]['updatecount'] . " records.\n";
+            }
+
             // import (check if dry run)
             if ($_opts->d && $_opts->v) {
                 print_r($result[$filename]['results']->toArray());