Skip to content

Instantly share code, notes, and snippets.

@gsherwood
Created December 18, 2014 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsherwood/93109eb0250c0ff98ec6 to your computer and use it in GitHub Desktop.
Save gsherwood/93109eb0250c0ff98ec6 to your computer and use it in GitHub Desktop.
phpcbf temp.php --standard=PSR2 --tab-width=4
<?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