Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
79
vendor/symfony/serializer/Tests/Mapping/AttributeMetadataTest.php
vendored
Normal file
79
vendor/symfony/serializer/Tests/Mapping/AttributeMetadataTest.php
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?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\Mapping;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class AttributeMetadataTest extends TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$attributeMetadata = new AttributeMetadata('name');
|
||||
$this->assertInstanceOf('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface', $attributeMetadata);
|
||||
}
|
||||
|
||||
public function testGetName()
|
||||
{
|
||||
$attributeMetadata = new AttributeMetadata('name');
|
||||
$this->assertEquals('name', $attributeMetadata->getName());
|
||||
}
|
||||
|
||||
public function testGroups()
|
||||
{
|
||||
$attributeMetadata = new AttributeMetadata('group');
|
||||
$attributeMetadata->addGroup('a');
|
||||
$attributeMetadata->addGroup('a');
|
||||
$attributeMetadata->addGroup('b');
|
||||
|
||||
$this->assertEquals(array('a', 'b'), $attributeMetadata->getGroups());
|
||||
}
|
||||
|
||||
public function testMaxDepth()
|
||||
{
|
||||
$attributeMetadata = new AttributeMetadata('name');
|
||||
$attributeMetadata->setMaxDepth(69);
|
||||
|
||||
$this->assertEquals(69, $attributeMetadata->getMaxDepth());
|
||||
}
|
||||
|
||||
public function testMerge()
|
||||
{
|
||||
$attributeMetadata1 = new AttributeMetadata('a1');
|
||||
$attributeMetadata1->addGroup('a');
|
||||
$attributeMetadata1->addGroup('b');
|
||||
|
||||
$attributeMetadata2 = new AttributeMetadata('a2');
|
||||
$attributeMetadata2->addGroup('a');
|
||||
$attributeMetadata2->addGroup('c');
|
||||
$attributeMetadata2->setMaxDepth(2);
|
||||
|
||||
$attributeMetadata1->merge($attributeMetadata2);
|
||||
|
||||
$this->assertEquals(array('a', 'b', 'c'), $attributeMetadata1->getGroups());
|
||||
$this->assertEquals(2, $attributeMetadata1->getMaxDepth());
|
||||
}
|
||||
|
||||
public function testSerialize()
|
||||
{
|
||||
$attributeMetadata = new AttributeMetadata('attribute');
|
||||
$attributeMetadata->addGroup('a');
|
||||
$attributeMetadata->addGroup('b');
|
||||
$attributeMetadata->setMaxDepth(3);
|
||||
|
||||
$serialized = serialize($attributeMetadata);
|
||||
$this->assertEquals($attributeMetadata, unserialize($serialized));
|
||||
}
|
||||
}
|
83
vendor/symfony/serializer/Tests/Mapping/ClassMetadataTest.php
vendored
Normal file
83
vendor/symfony/serializer/Tests/Mapping/ClassMetadataTest.php
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?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\Mapping;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class ClassMetadataTest extends TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('name');
|
||||
$this->assertInstanceOf('Symfony\Component\Serializer\Mapping\ClassMetadataInterface', $classMetadata);
|
||||
}
|
||||
|
||||
public function testAttributeMetadata()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('c');
|
||||
|
||||
$a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
|
||||
$a1->method('getName')->willReturn('a1');
|
||||
|
||||
$a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
|
||||
$a2->method('getName')->willReturn('a2');
|
||||
|
||||
$classMetadata->addAttributeMetadata($a1);
|
||||
$classMetadata->addAttributeMetadata($a2);
|
||||
|
||||
$this->assertEquals(array('a1' => $a1, 'a2' => $a2), $classMetadata->getAttributesMetadata());
|
||||
}
|
||||
|
||||
public function testMerge()
|
||||
{
|
||||
$classMetadata1 = new ClassMetadata('c1');
|
||||
$classMetadata2 = new ClassMetadata('c2');
|
||||
|
||||
$ac1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
|
||||
$ac1->method('getName')->willReturn('a1');
|
||||
$ac1->method('getGroups')->willReturn(array('a', 'b'));
|
||||
|
||||
$ac2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
|
||||
$ac2->method('getName')->willReturn('a1');
|
||||
$ac2->method('getGroups')->willReturn(array('b', 'c'));
|
||||
|
||||
$classMetadata1->addAttributeMetadata($ac1);
|
||||
$classMetadata2->addAttributeMetadata($ac2);
|
||||
|
||||
$classMetadata1->merge($classMetadata2);
|
||||
|
||||
$ac1->method('getGroups')->willReturn('a', 'b', 'c');
|
||||
|
||||
$this->assertEquals(array('a1' => $ac1), $classMetadata2->getAttributesMetadata());
|
||||
}
|
||||
|
||||
public function testSerialize()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('a');
|
||||
|
||||
$a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
|
||||
$a1->method('getName')->willReturn('b1');
|
||||
|
||||
$a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
|
||||
$a2->method('getName')->willReturn('b2');
|
||||
|
||||
$classMetadata->addAttributeMetadata($a1);
|
||||
$classMetadata->addAttributeMetadata($a2);
|
||||
|
||||
$serialized = serialize($classMetadata);
|
||||
$this->assertEquals($classMetadata, unserialize($serialized));
|
||||
}
|
||||
}
|
68
vendor/symfony/serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php
vendored
Normal file
68
vendor/symfony/serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?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\Mapping\Factory;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class CacheMetadataFactoryTest extends TestCase
|
||||
{
|
||||
public function testGetMetadataFor()
|
||||
{
|
||||
$metadata = new ClassMetadata(Dummy::class);
|
||||
|
||||
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
|
||||
$decorated
|
||||
->expects($this->once())
|
||||
->method('getMetadataFor')
|
||||
->will($this->returnValue($metadata))
|
||||
;
|
||||
|
||||
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
|
||||
|
||||
$this->assertEquals($metadata, $factory->getMetadataFor(Dummy::class));
|
||||
// The second call should retrieve the value from the cache
|
||||
$this->assertEquals($metadata, $factory->getMetadataFor(Dummy::class));
|
||||
}
|
||||
|
||||
public function testHasMetadataFor()
|
||||
{
|
||||
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
|
||||
$decorated
|
||||
->expects($this->once())
|
||||
->method('hasMetadataFor')
|
||||
->will($this->returnValue(true))
|
||||
;
|
||||
|
||||
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
|
||||
|
||||
$this->assertTrue($factory->hasMetadataFor(Dummy::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testInvalidClassThrowsException()
|
||||
{
|
||||
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
|
||||
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
|
||||
|
||||
$factory->getMetadataFor('Not\Exist');
|
||||
}
|
||||
}
|
79
vendor/symfony/serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php
vendored
Normal file
79
vendor/symfony/serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?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\Mapping\Factory;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\LoaderChain;
|
||||
use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class ClassMetadataFactoryTest extends TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$classMetadata = new ClassMetadataFactory(new LoaderChain(array()));
|
||||
$this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface', $classMetadata);
|
||||
}
|
||||
|
||||
public function testGetMetadataFor()
|
||||
{
|
||||
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
|
||||
$classMetadata = $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
|
||||
$this->assertEquals(TestClassMetadataFactory::createClassMetadata(true, true), $classMetadata);
|
||||
}
|
||||
|
||||
public function testHasMetadataFor()
|
||||
{
|
||||
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
|
||||
$this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'));
|
||||
$this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummyParent'));
|
||||
$this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummyInterface'));
|
||||
$this->assertFalse($factory->hasMetadataFor('Dunglas\Entity'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testCacheExists()
|
||||
{
|
||||
$cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
|
||||
$cache
|
||||
->expects($this->once())
|
||||
->method('fetch')
|
||||
->will($this->returnValue('foo'))
|
||||
;
|
||||
|
||||
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $cache);
|
||||
$this->assertEquals('foo', $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testCacheNotExists()
|
||||
{
|
||||
$cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
|
||||
$cache->method('fetch')->will($this->returnValue(false));
|
||||
$cache->method('save');
|
||||
|
||||
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $cache);
|
||||
$metadata = $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
|
||||
$this->assertEquals(TestClassMetadataFactory::createClassMetadata(true, true), $metadata);
|
||||
}
|
||||
}
|
77
vendor/symfony/serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php
vendored
Normal file
77
vendor/symfony/serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?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\Mapping\Loader;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
||||
use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class AnnotationLoaderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var AnnotationLoader
|
||||
*/
|
||||
private $loader;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->loader = new AnnotationLoader(new AnnotationReader());
|
||||
}
|
||||
|
||||
public function testInterface()
|
||||
{
|
||||
$this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Loader\LoaderInterface', $this->loader);
|
||||
}
|
||||
|
||||
public function testLoadClassMetadataReturnsTrueIfSuccessful()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
|
||||
$this->assertTrue($this->loader->loadClassMetadata($classMetadata));
|
||||
}
|
||||
|
||||
public function testLoadGroups()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
$this->loader->loadClassMetadata($classMetadata);
|
||||
|
||||
$this->assertEquals(TestClassMetadataFactory::createClassMetadata(), $classMetadata);
|
||||
}
|
||||
|
||||
public function testLoadMaxDepth()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy');
|
||||
$this->loader->loadClassMetadata($classMetadata);
|
||||
|
||||
$attributesMetadata = $classMetadata->getAttributesMetadata();
|
||||
$this->assertEquals(2, $attributesMetadata['foo']->getMaxDepth());
|
||||
$this->assertEquals(3, $attributesMetadata['bar']->getMaxDepth());
|
||||
}
|
||||
|
||||
public function testLoadClassMetadataAndMerge()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
$parentClassMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummyParent');
|
||||
|
||||
$this->loader->loadClassMetadata($parentClassMetadata);
|
||||
$classMetadata->merge($parentClassMetadata);
|
||||
|
||||
$this->loader->loadClassMetadata($classMetadata);
|
||||
|
||||
$this->assertEquals(TestClassMetadataFactory::createClassMetadata(true), $classMetadata);
|
||||
}
|
||||
}
|
65
vendor/symfony/serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php
vendored
Normal file
65
vendor/symfony/serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?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\Mapping\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class XmlFileLoaderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var XmlFileLoader
|
||||
*/
|
||||
private $loader;
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->loader = new XmlFileLoader(__DIR__.'/../../Fixtures/serialization.xml');
|
||||
$this->metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
}
|
||||
|
||||
public function testInterface()
|
||||
{
|
||||
$this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Loader\LoaderInterface', $this->loader);
|
||||
}
|
||||
|
||||
public function testLoadClassMetadataReturnsTrueIfSuccessful()
|
||||
{
|
||||
$this->assertTrue($this->loader->loadClassMetadata($this->metadata));
|
||||
}
|
||||
|
||||
public function testLoadClassMetadata()
|
||||
{
|
||||
$this->loader->loadClassMetadata($this->metadata);
|
||||
|
||||
$this->assertEquals(TestClassMetadataFactory::createXmlCLassMetadata(), $this->metadata);
|
||||
}
|
||||
|
||||
public function testMaxDepth()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy');
|
||||
$this->loader->loadClassMetadata($classMetadata);
|
||||
|
||||
$attributesMetadata = $classMetadata->getAttributesMetadata();
|
||||
$this->assertEquals(2, $attributesMetadata['foo']->getMaxDepth());
|
||||
$this->assertEquals(3, $attributesMetadata['bar']->getMaxDepth());
|
||||
}
|
||||
}
|
80
vendor/symfony/serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php
vendored
Normal file
80
vendor/symfony/serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?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\Mapping\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class YamlFileLoaderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var YamlFileLoader
|
||||
*/
|
||||
private $loader;
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->loader = new YamlFileLoader(__DIR__.'/../../Fixtures/serialization.yml');
|
||||
$this->metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
}
|
||||
|
||||
public function testInterface()
|
||||
{
|
||||
$this->assertInstanceOf('Symfony\Component\Serializer\Mapping\Loader\LoaderInterface', $this->loader);
|
||||
}
|
||||
|
||||
public function testLoadClassMetadataReturnsTrueIfSuccessful()
|
||||
{
|
||||
$this->assertTrue($this->loader->loadClassMetadata($this->metadata));
|
||||
}
|
||||
|
||||
public function testLoadClassMetadataReturnsFalseWhenEmpty()
|
||||
{
|
||||
$loader = new YamlFileLoader(__DIR__.'/../../Fixtures/empty-mapping.yml');
|
||||
$this->assertFalse($loader->loadClassMetadata($this->metadata));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Serializer\Exception\MappingException
|
||||
*/
|
||||
public function testLoadClassMetadataReturnsThrowsInvalidMapping()
|
||||
{
|
||||
$loader = new YamlFileLoader(__DIR__.'/../../Fixtures/invalid-mapping.yml');
|
||||
$loader->loadClassMetadata($this->metadata);
|
||||
}
|
||||
|
||||
public function testLoadClassMetadata()
|
||||
{
|
||||
$this->loader->loadClassMetadata($this->metadata);
|
||||
|
||||
$this->assertEquals(TestClassMetadataFactory::createXmlCLassMetadata(), $this->metadata);
|
||||
}
|
||||
|
||||
public function testMaxDepth()
|
||||
{
|
||||
$classMetadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy');
|
||||
$this->loader->loadClassMetadata($classMetadata);
|
||||
|
||||
$attributesMetadata = $classMetadata->getAttributesMetadata();
|
||||
$this->assertEquals(2, $attributesMetadata['foo']->getMaxDepth());
|
||||
$this->assertEquals(3, $attributesMetadata['bar']->getMaxDepth());
|
||||
}
|
||||
}
|
82
vendor/symfony/serializer/Tests/Mapping/TestClassMetadataFactory.php
vendored
Normal file
82
vendor/symfony/serializer/Tests/Mapping/TestClassMetadataFactory.php
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?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\Mapping;
|
||||
|
||||
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class TestClassMetadataFactory
|
||||
{
|
||||
public static function createClassMetadata($withParent = false, $withInterface = false)
|
||||
{
|
||||
$expected = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
|
||||
$foo = new AttributeMetadata('foo');
|
||||
$foo->addGroup('a');
|
||||
$expected->addAttributeMetadata($foo);
|
||||
|
||||
$bar = new AttributeMetadata('bar');
|
||||
$bar->addGroup('b');
|
||||
$bar->addGroup('c');
|
||||
$bar->addGroup('name_converter');
|
||||
$expected->addAttributeMetadata($bar);
|
||||
|
||||
$fooBar = new AttributeMetadata('fooBar');
|
||||
$fooBar->addGroup('a');
|
||||
$fooBar->addGroup('b');
|
||||
$fooBar->addGroup('name_converter');
|
||||
$expected->addAttributeMetadata($fooBar);
|
||||
|
||||
$symfony = new AttributeMetadata('symfony');
|
||||
$expected->addAttributeMetadata($symfony);
|
||||
|
||||
if ($withParent) {
|
||||
$kevin = new AttributeMetadata('kevin');
|
||||
$kevin->addGroup('a');
|
||||
$expected->addAttributeMetadata($kevin);
|
||||
|
||||
$coopTilleuls = new AttributeMetadata('coopTilleuls');
|
||||
$coopTilleuls->addGroup('a');
|
||||
$coopTilleuls->addGroup('b');
|
||||
$expected->addAttributeMetadata($coopTilleuls);
|
||||
}
|
||||
|
||||
if ($withInterface) {
|
||||
$symfony->addGroup('a');
|
||||
$symfony->addGroup('name_converter');
|
||||
}
|
||||
|
||||
// load reflection class so that the comparison passes
|
||||
$expected->getReflectionClass();
|
||||
|
||||
return $expected;
|
||||
}
|
||||
|
||||
public static function createXmlCLassMetadata()
|
||||
{
|
||||
$expected = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
|
||||
|
||||
$foo = new AttributeMetadata('foo');
|
||||
$foo->addGroup('group1');
|
||||
$foo->addGroup('group2');
|
||||
$expected->addAttributeMetadata($foo);
|
||||
|
||||
$bar = new AttributeMetadata('bar');
|
||||
$bar->addGroup('group2');
|
||||
$expected->addAttributeMetadata($bar);
|
||||
|
||||
return $expected;
|
||||
}
|
||||
}
|
Reference in a new issue