]> git.immae.eu Git - github/wallabag/wallabag.git/blame - vendor/symfony/translation/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php
gitignore vendor
[github/wallabag/wallabag.git] / vendor / symfony / translation / Symfony / Component / Translation / Tests / IdentityTranslatorTest.php
CommitLineData
4f5b44bd
NL
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Translation\Tests;
13
14use Symfony\Component\Translation\IdentityTranslator;
15use Symfony\Component\Translation\MessageSelector;
16
17class IdentityTranslatorTest extends \PHPUnit_Framework_TestCase
18{
19 /**
20 * @dataProvider getTransTests
21 */
22 public function testTrans($expected, $id, $parameters)
23 {
24 $translator = new IdentityTranslator(new MessageSelector());
25
26 $this->assertEquals($expected, $translator->trans($id, $parameters));
27 }
28
29 /**
30 * @dataProvider getTransChoiceTests
31 */
32 public function testTransChoice($expected, $id, $number, $parameters)
33 {
34 $translator = new IdentityTranslator(new MessageSelector());
35
36 $this->assertEquals($expected, $translator->transChoice($id, $number, $parameters));
37 }
38
39 // noop
40 public function testGetSetLocale()
41 {
42 $translator = new IdentityTranslator(new MessageSelector());
43 $translator->setLocale('en');
44 $translator->getLocale();
45 }
46
47 public function getTransTests()
48 {
49 return array(
50 array('Symfony2 is great!', 'Symfony2 is great!', array()),
51 array('Symfony2 is awesome!', 'Symfony2 is %what%!', array('%what%' => 'awesome')),
52 );
53 }
54
55 public function getTransChoiceTests()
56 {
57 return array(
58 array('There is 10 apples', '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples', 10, array('%count%' => 10)),
59 );
60 }
61}