DependencyInjectionExtension example


        $typeExtension1 = new TestTypeExtension();
        $typeExtension2 = new TestTypeExtension();
        $typeExtension3 = new OtherTypeExtension();
        $typeExtension4 = new MultipleTypesTypeExtension();

        $extensions = [
            'test' => new \ArrayIterator([$typeExtension1$typeExtension2$typeExtension4]),
            'other' => new \ArrayIterator([$typeExtension3$typeExtension4]),
        ];

        $extension = new DependencyInjectionExtension(new ContainerBuilder()$extensions[]);

        $this->assertTrue($extension->hasTypeExtensions('test'));
        $this->assertTrue($extension->hasTypeExtensions('other'));
        $this->assertFalse($extension->hasTypeExtensions('unknown'));
        $this->assertSame([$typeExtension1$typeExtension2$typeExtension4]$extension->getTypeExtensions('test'));
        $this->assertSame([$typeExtension3$typeExtension4]$extension->getTypeExtensions('other'));
    }

    public function testThrowExceptionForInvalidExtendedType()
    {
        $this->expectException(InvalidArgumentException::class);
        
Home | Imprint | This part of the site doesn't use cookies.