SalesChannelDefinitionInstanceRegistry example

/** * @internal */
#[Package('sales-channel')] class SalesChannelDefinitionInstanceRegistryTest extends TestCase
{
    use IntegrationTestBehaviour;

    public function testRegister(): void
    {
        $registry = new SalesChannelDefinitionInstanceRegistry(
            'sales_channel_definition.',
            new Container(),
            [],
            []
        );

        $registry->register(new ProductDefinition());

        static::assertInstanceOf(ProductDefinition::class$registry->get(ProductDefinition::class));
        static::assertTrue($registry->has(ProductDefinition::ENTITY_NAME));
        static::assertInstanceOf(ProductDefinition::class$registry->getByEntityName(ProductDefinition::ENTITY_NAME));
        
static::assertArrayHasKey(0, $encoded['lineItems']);
        static::assertArrayHasKey('payload', $encoded['lineItems'][0]);
        static::assertIsArray($encoded['lineItems'][0]['payload']);
        static::assertArrayHasKey('foo', $encoded['lineItems'][0]['payload']);
        static::assertArrayNotHasKey('bar', $encoded['lineItems'][0]['payload']);
    }

    private function getChainRegistry(StaticDefinitionInstanceRegistry $registry): DefinitionRegistryChain
    {
        $mock = $this->createMock(ContainerInterface::class);

        return new DefinitionRegistryChain($registrynew SalesChannelDefinitionInstanceRegistry('', $mock[][]));
    }
}

/** * @internal */
class ExtendedProductEntity extends ProductEntity
{
    public string $notExposed = 'test';
}

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