filled example

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[]);

        static::assertFalse($event->filled());

        $ids = new IdsCollection();

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

        $command = new DeleteCommand(
            $registry->getByEntityName('product'),
            [
throw $e;
        }
    }

    /** * @param list<WriteCommand> $commands */
    private function executeCommands(array $commands, WriteContext $context): void
    {
        $entityDeleteEvent = EntityDeleteEvent::create($context$commands);
        $entityDeleteEventLegacy = BeforeDeleteEvent::create($context$commands);
        if ($entityDeleteEvent->filled()) {
            $this->eventDispatcher->dispatch($entityDeleteEvent);

            Feature::ifNotActive('v6.6.0.0', fn () => $this->eventDispatcher->dispatch($entityDeleteEventLegacy));
        }

        // throws exception on violation and then aborts/rollbacks this transaction         $event = new PreWriteValidationEvent($context$commands);
        $this->eventDispatcher->dispatch($event);
        /** @var list<WriteCommand> $commands */
        $commands = $event->getCommands();

        
$delete = [['id' => $id1]['id' => $id2]];

        $spy = $this->eventListenerCalledSpy();

        $this->getContainer()->get('event_dispatcher')->addListener($eventClass$spy);

        $this->productRepository->delete($delete, Context::createDefaultContext());

        /** @var EntityDeleteEvent $event */
        $event = $spy->event;
        static::assertInstanceOf($eventClass$event);
        static::assertTrue($event->filled());
        static::assertEquals([$id1$id2]$event->getIds('product'));
    }

    /** * @dataProvider eventClasses */
    public function testEntityDeleteEventSuccessCallbacksCalled(string $eventClass): void
    {
        $id1 = $this->ids->get('product');

        $delete = [['id' => $id1]];

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