localeDir = TMP . 'Locale' . DS; $this->useCommandRunner(); $this->setAppNamespace(); } /** * Teardown * * @return void */ public function tearDown(): void { parent::tearDown(); $deDir = $this->localeDir . 'de_DE' . DS; 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'); } } /** * Tests that init() creates the PO files from POT files. * * @return void */ public function testInit() { $deDir = $this->localeDir . 'de_DE' . DS; if (!is_dir($deDir)) { mkdir($deDir, 0770, true); } file_put_contents($this->localeDir . 'default.pot', 'Testing POT file.'); file_put_contents($this->localeDir . 'cake.pot', 'Testing POT file.'); if (file_exists($deDir . 'default.po')) { unlink($deDir . 'default.po'); } if (file_exists($deDir . 'default.po')) { unlink($deDir . 'cake.po'); } $this->exec('i18n init --verbose', [ 'de_DE', $this->localeDir, ]); $this->assertExitSuccess(); $this->assertOutputContains('Generated 2 PO files'); $this->assertFileExists($deDir . 'default.po'); $this->assertFileExists($deDir . 'cake.po'); } /** * Test that the option parser is shaped right. * * @return void */ public function testGetOptionParser() { $this->exec('i18n -h'); $this->assertExitSuccess(); $this->assertOutputContains('cake i18n'); } /** * Tests main interactive mode * * @return void */ public function testInteractiveQuit() { $this->exec('i18n', ['q']); $this->assertExitSuccess(); } /** * Tests main interactive mode * * @return void */ public function testInteractiveHelp() { $this->exec('i18n', ['h', 'q']); $this->assertExitSuccess(); $this->assertOutputContains('cake i18n'); } /** * Tests main interactive mode * * @return void */ public function testInteractiveInit() { $this->exec('i18n', [ 'i', 'x', ]); $this->assertExitError(); $this->assertErrorContains('Invalid language code'); } }