ProductDefinition example


        );

        $seoUrlUpdater = $this->createSeoUrlUpdater(
            [
                new LanguageCollection([]),
            ],
            [
                new SalesChannelCollection([]),
            ],
            [
                new ProductPageSeoUrlRoute(new ProductDefinition()),
            ]
        );

        $this->seoUrlPersister->expects(static::never())->method('updateSeoUrls');

        $seoUrlUpdater->update('frontend.detail.page', []);
    }

    public function testUpdateGetPersisted(): void
    {
        $this->connection->method('fetchAllAssociative')->willReturn([
            [

class EntityWriteEventTest extends TestCase
{
    public function testGetters(): void
    {
        $ids = new IdsCollection();

        $context = Context::createDefaultContext();
        $writeContext = WriteContext::createFromContext($context);

        $registry = new StaticDefinitionInstanceRegistry(
            [new ProductDefinition()],
            $this->createMock(ValidatorInterface::class),
            $this->createMock(EntityWriteGatewayInterface::class)
        );

        $command = new DeleteCommand(
            $registry->getByEntityName('product'),
            ['id' => $ids->get('p1')],
            new EntityExistence('product', ['id' => $ids->get('p1')], true, true, true, [])
        );

        $event = EntityWriteEvent::create($writeContext[
            
$reader = $this->createMock(EntityReaderInterface::class);
        $reader->expects(static::once())->method('read');

        $searcher = $this->createMock(EntitySearcherInterface::class);
        $searcher->expects(static::never())->method('search');

        $aggregator = $this->createMock(EntityAggregatorInterface::class);
        $aggregator->expects(static::once())->method('aggregate');

        $repo = new EntityRepository(
            new ProductDefinition(),
            $reader,
            $this->createMock(VersionManager::class),
            $searcher,
            $aggregator,
            $eventDispatcher,
            $this->createMock(EntityLoadedEventFactory::class),
        );

        $criteria = new Criteria();
        $criteria->setTitle('foo');
        $criteria->addAggregation(new TermsAggregation('test', 'test'));
        
static::assertSame($data['displayParent']$result['displayParent']);
        static::assertSame($data['mainVariantId']$result['mainVariantId']);
        static::assertSame($data['configuratorGroupConfig']$result['configuratorGroupConfig']);
    }

    public function testEncodeThrowExceptionOnWrongField(): void
    {
        $field = new JsonField('variant_listing_config', 'variantListingConfig');
        $existence = new EntityExistence('test', ['someId' => 'foo'], true, false, false, []);
        $keyPair = new KeyValuePair('someId', null, false);
        $bag = new WriteParameterBag(
            new ProductDefinition(),
            WriteContext::createFromContext(Context::createDefaultContext()),
            '',
            new WriteCommandQueue()
        );

        try {
            iterator_to_array($this->serializer->encode($field$existence$keyPair$bag));
            static::fail('encode with incorrect field');
        } catch (DataAbstractionLayerException $e) {
            static::assertSame(DataAbstractionLayerException::INVALID_FIELD_SERIALIZER_CODE, $e->getErrorCode());
        }
    }

class ElasticsearchRegistryTest extends TestCase
{
    public function testRegistry(): void
    {
        $definition = $this->createMock(ElasticsearchProductDefinition::class);
        $definition
            ->method('getEntityDefinition')
            ->willReturn(new ProductDefinition());

        $registry = new ElasticsearchRegistry([
            $definition,
        ]);

        static::assertTrue($registry->has('product'));
        static::assertInstanceOf(ElasticsearchProductDefinition::class$registry->get('product'));

        static::assertFalse($registry->has('category'));
        static::assertNull($registry->get('category'));

        
static::assertInstanceOf(ChangeSetAware::class$command);
            static::assertTrue($command->requiresChangeSet());
        }
    }

    public function testDetectChangesetWithInvalidCommands(): void
    {
        $event = EntityDeleteEvent::create(
            WriteContext::createFromContext(Context::createDefaultContext()),
            [
                new DeleteCommand(
                    new ProductDefinition(),
                    [
                        'id' => 'foo',
                    ],
                    new EntityExistence(ProductDefinition::ENTITY_NAME, ['id' => 'foo'], true, false, false, [])
                ),
                new InsertCommand(
                    new ProductReviewDefinition(),
                    ['id' => 'foo'],
                    ['id' => 'foo'],
                    new EntityExistence(ProductReviewDefinition::ENTITY_NAME, ['id' => 'foo'], true, false, false, []),
                    '/bar'
                ),


    public function testOnLanguageWrittenWithoutInsertOperation(): void
    {
        Feature::skipTestIfInActive('ES_MULTILINGUAL_INDEX', $this);

        $esHelper = $this->createMock(ElasticsearchHelper::class);
        $esHelper->expects(static::once())->method('allowIndexing')->willReturn(true);

        $writeResult = new EntityWriteResult(Uuid::randomHex()[], ProductDefinition::ENTITY_NAME, EntityWriteResult::OPERATION_UPDATE);
        $registry = $this->createMock(ElasticsearchRegistry::class);
        $registry->expects(static::never())->method('getDefinitions')->willReturn([new ProductDefinition()]);

        $subscriber = new LanguageSubscriber(
            $esHelper,
            $registry,
            $this->createMock(Client::class),
            $this->createMock(ProductDefinition::class),
            $this->createMock(MessageBusInterface::class)
        );

        $event = $this->createMock(EntityWrittenEvent::class);
        $event
            

    private IdsCollection $ids;

    protected function setUp(): void
    {
        $this->ids = new IdsCollection();
    }

    public function getDefinition(): ProductDefinition
    {
        new StaticDefinitionInstanceRegistry(
            [$definition = new ProductDefinition()],
            $this->createMock(ValidatorInterface::class),
            $this->createMock(EntityWriteGatewayInterface::class)
        );

        return $definition;
    }

    public function testBeforeWriteOnlyReactsToLiveVersions(): void
    {
        $context = Context::createDefaultContext()->createWithVersionId($this->ids->create('version'));

        
class ProductSearchBuilderTest extends TestCase
{
    /** * @dataProvider providerQueries * * @param array<string>|string $query */
    public function testArraySearchTerm(array|string $query, string $expected): void
    {
        $criteria = new Criteria();
        $request = new Request();
        $productDefinition = new ProductDefinition();
        $request->query->set('search', $query);
        $context = Context::createDefaultContext();
        $mockSalesChannelContext = $this->createMock(SalesChannelContext::class);
        $mockSalesChannelContext->method('getContext')->willReturn($context);

        $mockProductSearchBuilder = $this->createMock(ProductSearchBuilder::class);
        $mockProductSearchBuilder->method('build')->willThrowException(new \Exception('Should not be called'));

        $mockElasticsearchHelper = $this->createMock(ElasticsearchHelper::class);
        $mockElasticsearchHelper->expects(static::once())->method('allowSearch')->with($productDefinition$context$criteria)->willReturn(true);

        
true,
            'prefix',
            true,
            $this->createMock(Client::class),
            $this->createMock(ElasticsearchRegistry::class),
            $this->createMock(CriteriaParser::class),
            $this->createMock(LoggerInterface::class),
            $storage
        );

        if (Feature::isActive('ES_MULTILINGUAL_INDEX')) {
            static::assertSame('prefix_product', $helper->getIndexName(new ProductDefinition()));
        } else {
            static::assertSame('prefix_product_foo', $helper->getIndexName(new ProductDefinition(), 'foo'));
        }
    }

    public function testAllowSearch(): void
    {
        $registry = $this->createMock(ElasticsearchRegistry::class);
        $registry->method('has')->willReturnMap([
            ['product', true],
            ['category', false],
        ]);
$this->createMock(EntityAggregatorInterface::class),
            $this->createMock(AbstractElasticsearchAggregationHydrator::class),
            new EventDispatcher(),
            '10s'
        );

        $context = Context::createDefaultContext();

        $criteria->addState(Criteria::STATE_ELASTICSEARCH_AWARE);

        $searcher->aggregate(
            new ProductDefinition(),
            $criteria,
            $context
        );
    }
}
if (Feature::isActive('v6.6.0.0')) {
            static::expectException(DataAbstractionLayerException::class);
        } else {
            static::expectException(InvalidSerializerFieldException::class);
        }

        $existence = new EntityExistence('product', [], false, false, false, []);
        $field = new StringField('password', 'password');

        $kv = new KeyValuePair($field->getPropertyName(), null, true);

        $params = new WriteParameterBag(new ProductDefinition(), WriteContext::createFromContext(Context::createDefaultContext()), '', new WriteCommandQueue());

        $this->serializer->encode($field$existence$kv$params)->getReturn();
    }

    /** * @dataProvider encodeProvider * * @param array<int, Constraint> $constraints */
    public function testEncode(string $for, int $minPasswordValue, array $constraints, bool $shouldThrowViolationException, ?string $inputPassword): void
    {
        

    private RequestCriteriaBuilder $requestCriteriaBuilder;

    private StaticDefinitionInstanceRegistry $staticDefinitionRegistry;

    protected function setUp(): void
    {
        $aggregationParser = new AggregationParser();

        $this->staticDefinitionRegistry = new StaticDefinitionInstanceRegistry(
            [
                new ProductDefinition(),
                new ProductOptionDefinition(),
                new PropertyGroupOptionDefinition(),
                new ProductPriceDefinition(),
                new ProductCategoryDefinition(),
                new CategoryDefinition(),
            ],
            $this->createMock(ValidatorInterface::class),
            $this->createMock(EntityWriteGatewayInterface::class)
        );

        $this->requestCriteriaBuilder = new RequestCriteriaBuilder(
            

class EntityDeleteEventTest extends TestCase
{
    public function testGetters(): void
    {
        $ids = new IdsCollection();

        $context = Context::createDefaultContext();
        $writeContext = WriteContext::createFromContext($context);

        $registry = new StaticDefinitionInstanceRegistry(
            [new ProductDefinition()],
            $this->createMock(ValidatorInterface::class),
            $this->createMock(EntityWriteGatewayInterface::class)
        );

        $command = new DeleteCommand(
            $registry->getByEntityName('product'),
            ['id' => $ids->get('p1')],
            new EntityExistence('product', ['id' => $ids->get('p1')], true, true, true, [])
        );

        $event = EntityDeleteEvent::create($writeContext[
            
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::assertInstanceOf(ProductDefinition::class$registry->getByEntityClass(new ProductEntity()));
    }

    public function testItThrowsExceptionWhenSalesChannelRepositoryWasNotFoundByEntityName(): void
    {
        $registry = new SalesChannelDefinitionInstanceRegistry(
            'sales_channel_definition.',
            
Home | Imprint | This part of the site doesn't use cookies.