I18nShellTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.8
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\Shell;
  16. use Cake\Cache\Cache;
  17. use Cake\Datasource\ConnectionManager;
  18. use Cake\Shell\I18nShell;
  19. use Cake\TestSuite\TestCase;
  20. /**
  21. * I18nShell test.
  22. */
  23. class I18nShellTest extends TestCase
  24. {
  25. /**
  26. * setup method
  27. *
  28. * @return void
  29. */
  30. public function setUp()
  31. {
  32. parent::setUp();
  33. $this->io = $this->getMock('Cake\Console\ConsoleIo');
  34. $this->shell = new I18nShell($this->io);
  35. }
  36. /**
  37. * Teardown
  38. *
  39. * @return void
  40. */
  41. public function tearDown()
  42. {
  43. parent::tearDown();
  44. }
  45. /**
  46. * Tests that init() creates the PO files from POT files.
  47. *
  48. * @return void
  49. */
  50. public function testInit()
  51. {
  52. $localeDir = TMP . 'Locale' . DS;
  53. $deDir = $localeDir . 'de' . DS;
  54. if (!is_dir($deDir)) {
  55. mkdir($deDir, 0770, true);
  56. }
  57. file_put_contents($localeDir . 'default.pot', 'Testing POT file.');
  58. file_put_contents($localeDir . 'cake.pot', 'Testing POT file.');
  59. if (file_exists($deDir . 'default.po')) {
  60. unlink($deDir . 'default.po');
  61. }
  62. if (file_exists($deDir . 'default.po')) {
  63. unlink($deDir . 'cake.po');
  64. }
  65. $this->shell->io()->expects($this->at(0))
  66. ->method('ask')
  67. ->will($this->returnValue('de'));
  68. $this->shell->io()->expects($this->at(1))
  69. ->method('ask')
  70. ->will($this->returnValue($localeDir));
  71. $this->shell->params['verbose'] = true;
  72. $this->shell->init();
  73. $this->assertTrue(file_exists($deDir . 'default.po'));
  74. $this->assertTrue(file_exists($deDir . 'cake.po'));
  75. }
  76. }