Browse Source

Add tests for I18nShell option parser.

Make sure the option parser calls don't raise exceptions and that the
expected subcommands exist.
Mark Story 10 years ago
parent
commit
d26703758a
1 changed files with 21 additions and 5 deletions
  1. 21 5
      tests/TestCase/Shell/I18nShellTest.php

+ 21 - 5
tests/TestCase/Shell/I18nShellTest.php

@@ -50,11 +50,14 @@ class I18nShellTest extends TestCase
 
         $deDir = $this->localeDir . 'de_DE' . DS;
 
-        unlink($this->localeDir . 'default.pot');
-        unlink($this->localeDir . 'cake.pot');
-
-        unlink($deDir . 'default.po');
-        unlink($deDir . 'cake.po');
+        if (file_exists($this->localeDir . 'default.pot')) {
+            unlink($this->localeDir . 'default.pot');
+            unlink($this->localeDir . 'cake.pot');
+        }
+        if (file_exists($deDir . 'default.po')) {
+            unlink($deDir . 'default.po');
+            unlink($deDir . 'cake.po');
+        }
     }
 
     /**
@@ -90,4 +93,17 @@ class I18nShellTest extends TestCase
         $this->assertFileExists($deDir . 'default.po');
         $this->assertFileExists($deDir . 'cake.po');
     }
+
+    /**
+     * Test that the option parser is shaped right.
+     *
+     * @return void
+     */
+    public function testGetOptionParser()
+    {
+        $this->shell->loadTasks();
+        $parser = $this->shell->getOptionParser();
+        $this->assertArrayHasKey('init', $parser->subcommands());
+        $this->assertArrayHasKey('extract', $parser->subcommands());
+    }
 }