|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> |
| 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://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests |
| 12 | + * @since 3.0.0 |
| 13 | + * @license http://www.opensource.org/licenses/mit-license.php MIT License |
| 14 | + */ |
| 15 | +namespace Cake\Test\TestCase\I18n; |
| 16 | + |
| 17 | +use Cake\Core\Configure; |
| 18 | +use Cake\I18n\MessagesFileLoader; |
| 19 | +use Cake\TestSuite\TestCase; |
| 20 | + |
| 21 | +/** |
| 22 | + * MessagesFileLoaderTest class |
| 23 | + * |
| 24 | + */ |
| 25 | +class MessagesFileLoaderTest extends TestCase { |
| 26 | + |
| 27 | +/** |
| 28 | + * Set Up |
| 29 | + * |
| 30 | + * @return void |
| 31 | + */ |
| 32 | + public function setUp() { |
| 33 | + parent::setUp(); |
| 34 | + $this->localePaths = Configure::read('App.paths.locales'); |
| 35 | + } |
| 36 | + |
| 37 | +/** |
| 38 | + * Tear down method |
| 39 | + * |
| 40 | + * @return void |
| 41 | + */ |
| 42 | + public function tearDown() { |
| 43 | + parent::tearDown(); |
| 44 | + Configure::write('App.paths.locales', $this->localePaths); |
| 45 | + } |
| 46 | + |
| 47 | +/** |
| 48 | + * test reading file from custom locale folder |
| 49 | + * |
| 50 | + * @return void |
| 51 | + */ |
| 52 | + public function testCustomLocalePath() { |
| 53 | + $loader = new MessagesFileLoader('default', 'en'); |
| 54 | + $package = $loader(); |
| 55 | + $messages = $package->getMessages(); |
| 56 | + $this->assertEquals('Po (translated)', $messages['Plural Rule 1']); |
| 57 | + |
| 58 | + Configure::write('App.paths.locales', [TEST_APP . 'custom_locale' . DS]); |
| 59 | + $loader = new MessagesFileLoader('default', 'en'); |
| 60 | + $package = $loader(); |
| 61 | + $messages = $package->getMessages(); |
| 62 | + $this->assertEquals('Po (translated) from custom folder', $messages['Plural Rule 1']); |
| 63 | + } |
| 64 | + |
| 65 | +} |
0 commit comments