Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
119
vendor/symfony/validator/Tests/Mapping/MemberMetadataTest.php
vendored
Normal file
119
vendor/symfony/validator/Tests/Mapping/MemberMetadataTest.php
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
<?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\Mapping;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Valid;
|
||||
use Symfony\Component\Validator\Mapping\MemberMetadata;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\ConstraintB;
|
||||
|
||||
class MemberMetadataTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $metadata;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->metadata = new TestMemberMetadata(
|
||||
'Symfony\Component\Validator\Tests\Fixtures\Entity',
|
||||
'getLastName',
|
||||
'lastName'
|
||||
);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->metadata = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAddValidSetsMemberToCascaded()
|
||||
{
|
||||
$result = $this->metadata->addConstraint(new Valid());
|
||||
|
||||
$this->assertEquals(array(), $this->metadata->getConstraints());
|
||||
$this->assertEquals($result, $this->metadata);
|
||||
$this->assertTrue($this->metadata->isCascaded());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAddOtherConstraintDoesNotSetMemberToCascaded()
|
||||
{
|
||||
$result = $this->metadata->addConstraint($constraint = new ConstraintA());
|
||||
|
||||
$this->assertEquals(array($constraint), $this->metadata->getConstraints());
|
||||
$this->assertEquals($result, $this->metadata);
|
||||
$this->assertFalse($this->metadata->isCascaded());
|
||||
}
|
||||
|
||||
public function testAddConstraintRequiresClassConstraints()
|
||||
{
|
||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||
|
||||
$this->metadata->addConstraint(new ClassConstraint());
|
||||
}
|
||||
|
||||
public function testSerialize()
|
||||
{
|
||||
$this->metadata->addConstraint(new ConstraintA(array('property1' => 'A')));
|
||||
$this->metadata->addConstraint(new ConstraintB(array('groups' => 'TestGroup')));
|
||||
|
||||
$metadata = unserialize(serialize($this->metadata));
|
||||
|
||||
$this->assertEquals($this->metadata, $metadata);
|
||||
}
|
||||
|
||||
public function testSerializeCollectionCascaded()
|
||||
{
|
||||
$this->metadata->addConstraint(new Valid(array('traverse' => true)));
|
||||
|
||||
$metadata = unserialize(serialize($this->metadata));
|
||||
|
||||
$this->assertEquals($this->metadata, $metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacySerializeCollectionCascadedDeeply()
|
||||
{
|
||||
$this->metadata->addConstraint(new Valid(array('traverse' => true)));
|
||||
|
||||
$metadata = unserialize(serialize($this->metadata));
|
||||
|
||||
$this->assertEquals($this->metadata, $metadata);
|
||||
}
|
||||
|
||||
public function testSerializeCollectionNotCascaded()
|
||||
{
|
||||
$this->metadata->addConstraint(new Valid(array('traverse' => false)));
|
||||
|
||||
$metadata = unserialize(serialize($this->metadata));
|
||||
|
||||
$this->assertEquals($this->metadata, $metadata);
|
||||
}
|
||||
}
|
||||
|
||||
class TestMemberMetadata extends MemberMetadata
|
||||
{
|
||||
public function getPropertyValue($object)
|
||||
{
|
||||
}
|
||||
|
||||
protected function newReflectionMember($object)
|
||||
{
|
||||
}
|
||||
}
|
Reference in a new issue