Created
December 18, 2014 21:46
-
-
Save gsherwood/93109eb0250c0ff98ec6 to your computer and use it in GitHub Desktop.
phpcbf temp.php --standard=PSR2 --tab-width=4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace I18nMessages\Test\I18n; | |
use Cake\TestSuite\TestCase; | |
use I18nMessages\I18n\DbMessagesLoader; | |
/** | |
* Tests for DbMessagesLoader | |
*/ | |
class DbMessagesLoaderTest extends TestCase | |
{ | |
/** | |
* fixtures | |
* | |
* @var array | |
*/ | |
public $fixtures = ['plugin.I18nMessages.I18nMessages']; | |
/** | |
* testInvoke method | |
* | |
* @param string $domain | |
* @param string $locale | |
* @param string $model | |
* @param array $expected | |
* @return void | |
* @dataProvider paramsProvider | |
*/ | |
public function testInvoke($domain, $locale, $model, $expected) | |
{ | |
$loader = new DbMessagesLoader($domain, $locale, $model); | |
$package = $loader(); | |
$this->assertEquals($expected, $package->getMessages()); | |
} | |
/** | |
* Data provider for testInvoke | |
* | |
* @return array | |
*/ | |
public function paramsProvider() | |
{ | |
return [ | |
[ | |
'default', | |
'en', | |
null, | |
[ | |
'test' => 'test translated', | |
'singular' => '{0} value', | |
'plural' => ['{0} value', '{0} values'] | |
] | |
], | |
[ | |
'default', | |
'fr', | |
null, | |
['test' => 'fr test translated'] | |
], | |
[ | |
'my_domain', | |
'en', | |
null, | |
['test' => 'domain test translated'] | |
], | |
[ | |
'w_context', | |
'en', | |
null, | |
[ | |
'test' => ['_context' => ['c1' => 'test translated']], | |
'singular' => [ | |
'_context' => [ | |
'c1' => '{0} value', | |
'c2' => '{0} value c2' | |
] | |
], | |
'plural' => [ | |
'_context' => [ | |
'c1' => ['{0} value', '{0} values'], | |
'c2' => ['{0} value c2', '{0} values c2'] | |
] | |
], | |
] | |
], | |
[ | |
'foo', | |
'bar', | |
null, | |
[] | |
] | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment