triggerChangeSet example

$manyToOneField = $fieldCollection->get('manyToOne');

        static::assertInstanceOf(OneToManyAssociationField::class$oneToManyField);
        static::assertInstanceOf(ManyToOneAssociationField::class$manyToOneField);

        $event = new PreWriteValidationEvent(WriteContext::createFromContext(Context::createDefaultContext())[
            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
    {
$stockSubscriber = new StockUpdater(
            $this->getConnectionMock(),
            $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)
            
Home | Imprint | This part of the site doesn't use cookies.