getWriteContext example

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

        $event = EntityWriteEvent::create($writeContext[
            $command,
        ]);

        static::assertSame($writeContext$event->getWriteContext());
        static::assertSame($context$event->getContext());
        static::assertSame([$command]$event->getCommands());
    }

    public function testGetCommandsForEntity(): void
    {
        $ids = new IdsCollection();

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

        
parent::tearDown();
    }

    public function testCreateShouldNotBeBlocked(): void
    {
        $data = [
            'id' => Uuid::randomHex(),
            'description' => 'foo',
        ];

        $r = $this->entityWriter->insert($this->testDefinition, [$data]$this->getWriteContext());

        static::assertCount(1, $r);
    }

    public function testCreateWithLockShouldNotBeWritten(): void
    {
        $data = [
            'id' => Uuid::randomHex(),
            'description' => 'foo',
            'locked' => true,
        ];

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

        $event = EntityDeleteEvent::create($writeContext[
            $command,
        ]);

        static::assertSame($writeContext$event->getWriteContext());
        static::assertSame($context$event->getContext());
        static::assertSame([$command]$event->getCommands());
    }

    public function testFilled(): void
    {
        $context = Context::createDefaultContext();
        $writeContext = WriteContext::createFromContext($context);

        $event = EntityDeleteEvent::create($writeContext[]);

        
$this->addEventListener(
            $this->getContainer()->get('event_dispatcher'),
            PreWriteValidationEvent::class,
            function DPreWriteValidationEvent $event) use (&$called): void {
                // we also get a validation event for the version tables                 if (!$event->getPrimaryKeys('product')) {
                    return;
                }

                $called = true;
                // some validators depend on that to disable insert/update validation for merge requests                 static::assertTrue($event->getWriteContext()->hasState(VersionManager::MERGE_SCOPE));
            }
        );

        $this->getContainer()->get('product.repository')->merge($versionId$context);

        static::assertTrue($called);
    }

    public function testWhenNotAddingFKThenItShouldNotBeAvailable(): void
    {
        $product = (new ProductBuilder($this->ids, self::PRODUCT_ID))->stock(1)
            
Home | Imprint | This part of the site doesn't use cookies.