requiresChangeSet example

new DeleteCommand($oneToManyField->getReferenceDefinition()[]$this->createMock(EntityExistence::class)),
            new UpdateCommand($manyToOneField->getReferenceDefinition()[][]$this->createMock(EntityExistence::class), ''),
            new UpdateCommand($oneToManyField->getReferenceDefinition()['rule_id' => 'foo'][]$this->createMock(EntityExistence::class), ''),
        ]);

        $this->areaUpdater->triggerChangeSet($event);

        /** @var DeleteCommand[]|UpdateCommand[] $commands */
        $commands = $event->getCommands();

        static::assertCount(3, $commands);
        static::assertTrue($commands[0]->requiresChangeSet());
        static::assertFalse($commands[1]->requiresChangeSet());
        static::assertTrue($commands[2]->requiresChangeSet());
    }

    public function testOnEntityWritten(): void
    {
        $context = Context::createDefaultContext();

        $idA = Uuid::randomHex();
        $idB = Uuid::randomBytes();
        $idC = Uuid::randomBytes();
        

    private function generateChangeSets(array $commands): void
    {
        $primaryKeys = [];
        $definitions = [];

        foreach ($commands as $command) {
            if (!$command instanceof ChangeSetAware || !$command instanceof WriteCommand) {
                continue;
            }

            if (!$command->requiresChangeSet()) {
                continue;
            }

            $entity = $command->getDefinition()->getEntityName();

            $primaryKeys[$entity][] = $command->getPrimaryKey();
            $definitions[$entity] = $command->getDefinition();
        }

        if (empty($primaryKeys)) {
            return;
        }
new ProductReviewDefinition(),
                    [
                        'id' => 'foo',
                    ],
                    new EntityExistence(ProductReviewDefinition::ENTITY_NAME, ['id' => 'foo'], true, false, false, [])
                ),
            ]
        );

        foreach ($event->getCommands() as $command) {
            static::assertInstanceOf(ChangeSetAware::class$command);
            static::assertFalse($command->requiresChangeSet());
        }

        $this->productReviewSubscriber->detectChangeset($event);

        foreach ($event->getCommands() as $command) {
            static::assertInstanceOf(ChangeSetAware::class$command);
            static::assertTrue($command->requiresChangeSet());
        }
    }

    public function testDetectChangesetWithInvalidCommands(): void
    {
$this->dispatcher,
            new StockUpdateFilterProvider([]),
        );

        $writeContextMock = $this->getMockBuilder(WriteContext::class)
            ->disableOriginalConstructor()
            ->getMock();

        $event = new PreWriteValidationEvent($writeContextMock$commands);
        $stockSubscriber->triggerChangeSet($event);

        static::assertFalse($commands[0]->requiresChangeSet());
    }

    public function testTriggerChangeSetWithNonChangeSetAwareCommand(): void
    {
        $nonChangeSetAwareCommand = $this->createMock(WriteCommand::class);

        $commands = [$nonChangeSetAwareCommand];

        $writeContextMock = $this->getMockBuilder(WriteContext::class)
            ->disableOriginalConstructor()
            ->getMock();

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