!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/php54/usr/share/pear/test/Serializer/Symfony/Component/Serializer/Tests/Normalizer/   drwxr-xr-x
Free 294.17 GB of 429.69 GB (68.46%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     GetSetMethodNormalizerTest.php (8.26 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\Serializer\Tests\Normalizer;

use 
Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use 
Symfony\Component\Serializer\SerializerInterface;
use 
Symfony\Component\Serializer\Normalizer\NormalizerInterface;

class 
GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
{
    protected function 
setUp()
    {
        
$this->serializer $this->getMock(__NAMESPACE__.'\SerializerNormalizer');
        
$this->normalizer = new GetSetMethodNormalizer();
        
$this->normalizer->setSerializer($this->serializer);
    }

    public function 
testNormalize()
    {
        
$obj = new GetSetDummy();
        
$object = new \stdClass();
        
$obj->setFoo('foo');
        
$obj->setBar('bar');
        
$obj->setCamelCase('camelcase');
        
$obj->setObject($object);

        
$this->serializer
            
->expects($this->once())
            ->
method('normalize')
            ->
with($object'any')
            ->
will($this->returnValue('string_object'))
        ;

        
$this->assertEquals(
            array(
                
'foo' => 'foo',
                
'bar' => 'bar',
                
'fooBar' => 'foobar',
                
'camelCase' => 'camelcase',
                
'object' => 'string_object',
            ),
            
$this->normalizer->normalize($obj'any')
        );
    }

    public function 
testDenormalize()
    {
        
$obj $this->normalizer->denormalize(
            array(
'foo' => 'foo''bar' => 'bar''fooBar' => 'foobar'),
            
__NAMESPACE__.'\GetSetDummy',
            
'any'
        
);
        
$this->assertEquals('foo'$obj->getFoo());
        
$this->assertEquals('bar'$obj->getBar());
    }

    public function 
testDenormalizeOnCamelCaseFormat()
    {
        
$this->normalizer->setCamelizedAttributes(array('camel_case'));
        
$obj $this->normalizer->denormalize(
            array(
'camel_case' => 'camelCase'),
            
__NAMESPACE__.'\GetSetDummy'
        
);
        
$this->assertEquals('camelCase'$obj->getCamelCase());
    }

    
/**
     * @dataProvider attributeProvider
     */
    
public function testFormatAttribute($attribute$camelizedAttributes$result)
    {
        
$r = new \ReflectionObject($this->normalizer);
        
$m $r->getMethod('formatAttribute');
        
$m->setAccessible(true);

        
$this->normalizer->setCamelizedAttributes($camelizedAttributes);
        
$this->assertEquals($m->invoke($this->normalizer$attribute$camelizedAttributes), $result);
    }

    public function 
attributeProvider()
    {
        return array(
            array(
'attribute_test', array('attribute_test'),'AttributeTest'),
            array(
'attribute_test', array('any'),'attribute_test'),
            array(
'attribute', array('attribute'),'Attribute'),
            array(
'attribute', array(), 'attribute'),
        );
    }

    public function 
testConstructorDenormalize()
    {
        
$obj $this->normalizer->denormalize(
            array(
'foo' => 'foo''bar' => 'bar''fooBar' => 'foobar'),
            
__NAMESPACE__.'\GetConstructorDummy''any');
        
$this->assertEquals('foo'$obj->getFoo());
        
$this->assertEquals('bar'$obj->getBar());
    }

    
/**
     * @dataProvider provideCallbacks
     */
    
public function testCallbacks($callbacks$value$result$message)
    {
        
$this->normalizer->setCallbacks($callbacks);

        
$obj = new GetConstructorDummy(''$value);

        
$this->assertEquals(
            
$result,
            
$this->normalizer->normalize($obj'any'),
            
$message
        
);
    }

    
/**
     * @expectedException \InvalidArgumentException
     */
    
public function testUncallableCallbacks()
    {
        
$this->normalizer->setCallbacks(array('bar' => null));

        
$obj = new GetConstructorDummy('baz''quux');

        
$this->normalizer->normalize($obj'any');
    }

    public function 
testIgnoredAttributes()
    {
        
$this->normalizer->setIgnoredAttributes(array('foo''bar''camelCase''object'));

        
$obj = new GetSetDummy();
        
$obj->setFoo('foo');
        
$obj->setBar('bar');

        
$this->assertEquals(
            array(
'fooBar' => 'foobar'),
            
$this->normalizer->normalize($obj'any')
        );
    }

    public function 
provideCallbacks()
    {
        return array(
            array(
                array(
                    
'bar' => function ($bar) {
                        return 
'baz';
                    },
                ),
                
'baz',
                array(
'foo' => '''bar' => 'baz'),
                
'Change a string',
            ),
            array(
                array(
                    
'bar' => function ($bar) {
                        return 
null;
                    },
                ),
                
'baz',
                array(
'foo' => '''bar' => null),
                
'Null an item'
            
),
            array(
                array(
                    
'bar' => function ($bar) {
                        return 
$bar->format('d-m-Y H:i:s');
                    },
                ),
                new \
DateTime('2011-09-10 06:30:00'),
                array(
'foo' => '''bar' => '10-09-2011 06:30:00'),
                
'Format a date',
            ),
            array(
                array(
                    
'bar' => function ($bars) {
                        
$foos '';
                        foreach (
$bars as $bar) {
                            
$foos .= $bar->getFoo();
                        }

                        return 
$foos;
                    },
                ),
                array(new 
GetConstructorDummy('baz'''), new GetConstructorDummy('quux''')),
                array(
'foo' => '''bar' => 'bazquux'),
                
'Collect a property',
            ),
            array(
                array(
                    
'bar' => function ($bars) {
                        return 
count($bars);
                    },
                ),
                array(new 
GetConstructorDummy('baz'''), new GetConstructorDummy('quux''')),
                array(
'foo' => '''bar' => 2),
                
'Count a property',
            ),
        );
    }

    
/**
     * @expectedException \LogicException
     * @expectedExceptionMessage Cannot normalize attribute "object" because injected serializer is not a normalizer
     */
    
public function testUnableToNormalizeObjectAttribute()
    {
        
$serializer $this->getMock('Symfony\Component\Serializer\SerializerInterface');
        
$this->normalizer->setSerializer($serializer);

        
$obj    = new GetSetDummy();
        
$object = new \stdClass();
        
$obj->setObject($object);

        
$this->normalizer->normalize($obj'any');
    }
}

class 
GetSetDummy
{
    protected 
$foo;
    private 
$bar;
    protected 
$camelCase;
    protected 
$object;

    public function 
getFoo()
    {
        return 
$this->foo;
    }

    public function 
setFoo($foo)
    {
        
$this->foo $foo;
    }

    public function 
getBar()
    {
        return 
$this->bar;
    }

    public function 
setBar($bar)
    {
        
$this->bar $bar;
    }

    public function 
getFooBar()
    {
        return 
$this->foo.$this->bar;
    }

    public function 
getCamelCase()
    {
        return 
$this->camelCase;
    }

    public function 
setCamelCase($camelCase)
    {
        
$this->camelCase $camelCase;
    }

    public function 
otherMethod()
    {
        throw new \
RuntimeException("Dummy::otherMethod() should not be called");
    }

    public function 
setObject($object)
    {
        
$this->object $object;
    }

    public function 
getObject()
    {
        return 
$this->object;
    }
}

class 
GetConstructorDummy
{
    protected 
$foo;
    private 
$bar;

    public function 
__construct($foo$bar)
    {
        
$this->foo $foo;
        
$this->bar $bar;
    }

    public function 
getFoo()
    {
        return 
$this->foo;
    }

    public function 
getBar()
    {
        return 
$this->bar;
    }

    public function 
otherMethod()
    {
        throw new \
RuntimeException("Dummy::otherMethod() should not be called");
    }
}

abstract class 
SerializerNormalizer implements SerializerInterfaceNormalizerInterface
{
}

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