assertLoadedContexts example


        $classMetadata = new ClassMetadata($this->getNamespace().'\IgnoreDummy');
        $this->loader->loadClassMetadata($classMetadata);

        $attributesMetadata = $classMetadata->getAttributesMetadata();
        $this->assertTrue($attributesMetadata['ignored1']->isIgnored());
        $this->assertTrue($attributesMetadata['ignored2']->isIgnored());
    }

    public function testLoadContexts()
    {
        $this->assertLoadedContexts($this->getNamespace().'\ContextDummy', $this->getNamespace().'\ContextDummyParent');
    }

    public function testLoadContextsPropertiesPromoted()
    {
        $this->assertLoadedContexts($this->getNamespace().'\ContextDummyPromotedProperties', $this->getNamespace().'\ContextDummyParent');
    }

    public function testThrowsOnContextOnInvalidMethod()
    {
        $class = $this->getNamespace().'\BadMethodContextDummy';

        
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\ContextDummyParent;

/** * @author Maxime Steinhausser <maxime.steinhausser@gmail.com> */
trait ContextMappingTestTrait
{
    abstract protected function getLoaderForContextMapping(): LoaderInterface;

    public function testLoadContexts()
    {
        $this->assertLoadedContexts();
    }

    public function assertLoadedContexts(string $dummyClass = ContextDummy::class, string $parentClass = ContextDummyParent::class): void
    {
        $loader = $this->getLoaderForContextMapping();

        $classMetadata = new ClassMetadata($dummyClass);
        $parentClassMetadata = new ClassMetadata($parentClass);

        $loader->loadClassMetadata($parentClassMetadata);
        $classMetadata->merge($parentClassMetadata);

        
Home | Imprint | This part of the site doesn't use cookies.