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


Viewing file:     PropertyPathMapperTest.php (11.72 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\Form\Tests\Extension\Core\DataMapper;

use 
Symfony\Component\Form\FormConfigBuilder;
use 
Symfony\Component\Form\FormConfigInterface;
use 
Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;

class 
PropertyPathMapperTest extends \PHPUnit_Framework_TestCase
{
    
/**
     * @var PropertyPathMapper
     */
    
private $mapper;

    
/**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    
private $dispatcher;

    
/**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    
private $propertyAccessor;

    protected function 
setUp()
    {
        
$this->dispatcher $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
        
$this->propertyAccessor $this->getMock('Symfony\Component\PropertyAccess\PropertyAccessorInterface');
        
$this->mapper = new PropertyPathMapper($this->propertyAccessor);
    }

    
/**
     * @param $path
     * @return \PHPUnit_Framework_MockObject_MockObject
     */
    
private function getPropertyPath($path)
    {
        return 
$this->getMockBuilder('Symfony\Component\PropertyAccess\PropertyPath')
            ->
setConstructorArgs(array($path))
            ->
setMethods(array('getValue''setValue'))
            ->
getMock();
    }

    
/**
     * @param FormConfigInterface $config
     * @param Boolean $synchronized
     * @param Boolean $submitted
     * @return \PHPUnit_Framework_MockObject_MockObject
     */
    
private function getForm(FormConfigInterface $config$synchronized true$submitted true)
    {
        
$form $this->getMockBuilder('Symfony\Component\Form\Form')
            ->
setConstructorArgs(array($config))
            ->
setMethods(array('isSynchronized''isSubmitted'))
            ->
getMock();

        
$form->expects($this->any())
            ->
method('isSynchronized')
            ->
will($this->returnValue($synchronized));

        
$form->expects($this->any())
            ->
method('isSubmitted')
            ->
will($this->returnValue($submitted));

        return 
$form;
    }

    
/**
     * @return \PHPUnit_Framework_MockObject_MockObject
     */
    
private function getDataMapper()
    {
        return 
$this->getMock('Symfony\Component\Form\DataMapperInterface');
    }

    public function 
testMapDataToFormsPassesObjectRefIfByReference()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->once())
            ->
method('getValue')
            ->
with($car$propertyPath)
            ->
will($this->returnValue($engine));

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$form $this->getForm($config);

        
$this->mapper->mapDataToForms($car, array($form));

        
// Can't use isIdentical() above because mocks always clone their
        // arguments which can't be disabled in PHPUnit 3.6
        
$this->assertSame($engine$form->getData());
    }

    public function 
testMapDataToFormsPassesObjectCloneIfNotByReference()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->once())
            ->
method('getValue')
            ->
with($car$propertyPath)
            ->
will($this->returnValue($engine));

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(false);
        
$config->setPropertyPath($propertyPath);
        
$form $this->getForm($config);

        
$this->mapper->mapDataToForms($car, array($form));

        
$this->assertNotSame($engine$form->getData());
        
$this->assertEquals($engine$form->getData());
    }

    public function 
testMapDataToFormsIgnoresEmptyPropertyPath()
    {
        
$car = new \stdClass();

        
$config = new FormConfigBuilder(null'\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$form $this->getForm($config);

        
$this->assertNull($form->getPropertyPath());

        
$this->mapper->mapDataToForms($car, array($form));

        
$this->assertNull($form->getData());
    }

    public function 
testMapDataToFormsIgnoresUnmapped()
    {
        
$car = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->never())
            ->
method('getValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setMapped(false);
        
$config->setPropertyPath($propertyPath);
        
$form $this->getForm($config);

        
$this->mapper->mapDataToForms($car, array($form));

        
$this->assertNull($form->getData());
    }

    public function 
testMapDataToFormsSetsDefaultDataIfPassedDataIsNull()
    {
        
$default = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->never())
            ->
method('getValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($default);

        
$form $this->getMockBuilder('Symfony\Component\Form\Form')
            ->
setConstructorArgs(array($config))
            ->
setMethods(array('setData'))
            ->
getMock();

        
$form->expects($this->once())
            ->
method('setData')
            ->
with($default);

        
$this->mapper->mapDataToForms(null, array($form));
    }

    public function 
testMapDataToFormsSetsDefaultDataIfPassedDataIsEmptyArray()
    {
        
$default = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->never())
            ->
method('getValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($default);

        
$form $this->getMockBuilder('Symfony\Component\Form\Form')
            ->
setConstructorArgs(array($config))
            ->
setMethods(array('setData'))
            ->
getMock();

        
$form->expects($this->once())
            ->
method('setData')
            ->
with($default);

        
$this->mapper->mapDataToForms(array(), array($form));
    }

    public function 
testMapFormsToDataWritesBackIfNotByReference()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->once())
            ->
method('setValue')
            ->
with($car$propertyPath$engine);

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(false);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($engine);
        
$form $this->getForm($config);

        
$this->mapper->mapFormsToData(array($form), $car);
    }

    public function 
testMapFormsToDataWritesBackIfByReferenceButNoReference()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->once())
            ->
method('setValue')
            ->
with($car$propertyPath$engine);

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($engine);
        
$form $this->getForm($config);

        
$this->mapper->mapFormsToData(array($form), $car);
    }

    public function 
testMapFormsToDataWritesBackIfByReferenceAndReference()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
// $car already contains the reference of $engine
        
$this->propertyAccessor->expects($this->once())
            ->
method('getValue')
            ->
with($car$propertyPath)
            ->
will($this->returnValue($engine));

        
$this->propertyAccessor->expects($this->never())
            ->
method('setValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($engine);
        
$form $this->getForm($config);

        
$this->mapper->mapFormsToData(array($form), $car);
    }

    public function 
testMapFormsToDataIgnoresUnmapped()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->never())
            ->
method('setValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($engine);
        
$config->setMapped(false);
        
$form $this->getForm($config);

        
$this->mapper->mapFormsToData(array($form), $car);
    }

    public function 
testMapFormsToDataIgnoresUnsubmittedForms()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->never())
            ->
method('setValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($engine);
        
$form $this->getForm($configtruefalse);

        
$this->mapper->mapFormsToData(array($form), $car);
    }

    public function 
testMapFormsToDataIgnoresEmptyData()
    {
        
$car = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->never())
            ->
method('setValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData(null);
        
$form $this->getForm($config);

        
$this->mapper->mapFormsToData(array($form), $car);
    }

    public function 
testMapFormsToDataIgnoresUnsynchronized()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->never())
            ->
method('setValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($engine);
        
$form $this->getForm($configfalse);

        
$this->mapper->mapFormsToData(array($form), $car);
    }

    public function 
testMapFormsToDataIgnoresDisabled()
    {
        
$car = new \stdClass();
        
$engine = new \stdClass();
        
$propertyPath $this->getPropertyPath('engine');

        
$this->propertyAccessor->expects($this->never())
            ->
method('setValue');

        
$config = new FormConfigBuilder('name''\stdClass'$this->dispatcher);
        
$config->setByReference(true);
        
$config->setPropertyPath($propertyPath);
        
$config->setData($engine);
        
$config->setDisabled(true);
        
$form $this->getForm($config);

        
$this->mapper->mapFormsToData(array($form), $car);
    }
}

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