Server IP : 127.0.0.2 / Your IP : 3.144.252.197 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/symfony/translation/Tests/ |
Upload File : |
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Tests; use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Translation\IdentityTranslator; class IdentityTranslatorTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider getTransTests */ public function testTrans($expected, $id, $parameters) { $translator = new IdentityTranslator(); $this->assertEquals($expected, $translator->trans($id, $parameters)); } /** * @dataProvider getTransChoiceTests */ public function testTransChoiceWithExplicitLocale($expected, $id, $number, $parameters) { $translator = new IdentityTranslator(); $translator->setLocale('en'); $this->assertEquals($expected, $translator->transChoice($id, $number, $parameters)); } /** * @dataProvider getTransChoiceTests */ public function testTransChoiceWithDefaultLocale($expected, $id, $number, $parameters) { \Locale::setDefault('en'); $translator = new IdentityTranslator(); $this->assertEquals($expected, $translator->transChoice($id, $number, $parameters)); } public function testGetSetLocale() { $translator = new IdentityTranslator(); $translator->setLocale('en'); $this->assertEquals('en', $translator->getLocale()); } public function testGetLocaleReturnsDefaultLocaleIfNotSet() { // in order to test with "pt_BR" IntlTestHelper::requireFullIntl($this, false); $translator = new IdentityTranslator(); \Locale::setDefault('en'); $this->assertEquals('en', $translator->getLocale()); \Locale::setDefault('pt_BR'); $this->assertEquals('pt_BR', $translator->getLocale()); } public function getTransTests() { return array( array('Symfony is great!', 'Symfony is great!', array()), array('Symfony is awesome!', 'Symfony is %what%!', array('%what%' => 'awesome')), ); } public function getTransChoiceTests() { return array( array('There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0, array('%count%' => 0)), array('There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1, array('%count%' => 1)), array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10, array('%count%' => 10)), array('There are 0 apples', 'There is 1 apple|There are %count% apples', 0, array('%count%' => 0)), array('There is 1 apple', 'There is 1 apple|There are %count% apples', 1, array('%count%' => 1)), array('There are 10 apples', 'There is 1 apple|There are %count% apples', 10, array('%count%' => 10)), // custom validation messages may be coded with a fixed value array('There are 2 apples', 'There are 2 apples', 2, array('%count%' => 2)), ); } }