getNotFound example

$deleteResult = $this->getWriter()->delete(
            $this->getContainer()->get(CategoryDefinition::class),
            [
                ['id' => $id],
            ],
            $context
        );

        $exists = $this->connection->fetchAllAssociative('SELECT * FROM category WHERE id = :id', ['id' => Uuid::fromHexToBytes($id)]);
        static::assertEmpty($exists);
        static::assertEmpty($deleteResult->getNotFound());
        static::assertNotEmpty($deleteResult->getDeleted());
    }

    public function testMultiDelete(): void
    {
        $id = Uuid::randomHex();
        $id2 = Uuid::randomHex();

        $context = $this->createWriteContext();

        $this->getWriter()->insert(
            
if ($deletes->getEvents() !== null) {
            $writes->addEvent(...$deletes->getEvents()->getElements());
        }

        $this->eventDispatcher->dispatch($writes);

        $ids = $this->getWrittenEntities($result->getWritten());

        $deleted = $this->getWrittenEntitiesByEvent($deletes);

        $notFound = $this->getWrittenEntities($result->getNotFound());

        return new SyncResult($ids$notFound$deleted);
    }

    /** * @param array<string, EntityWriteResult[]> $grouped * * @return array<string, array<int, mixed>> */
    private function getWrittenEntities(array $grouped): array
    {
        
return $event;
    }

    /** * @param array<array<string, mixed|null>> $ids */
    public function delete(array $ids, Context $context): EntityWrittenContainerEvent
    {
        ReplicaConnection::ensurePrimary();

        $affected = $this->versionManager->delete($this->definition, $ids, WriteContext::createFromContext($context));
        $event = EntityWrittenContainerEvent::createWithDeletedEvents($affected->getDeleted()$context$affected->getNotFound());

        if ($affected->getWritten()) {
            $updates = EntityWrittenContainerEvent::createWithWrittenEvents($affected->getWritten()$context[]);

            if ($updates->getEvents() !== null) {
                $event->addEvent(...$updates->getEvents());
            }
        }

        $this->eventDispatcher->dispatch($event);

        
'product' => [
                'deleted-id',
            ],
        ]$result->getDeleted());

        static::assertSame([
            'product' => [
                'created-id',
            ],
        ]$result->getData());

        static::assertSame([]$result->getNotFound());
    }

    public function testWildcardDeleteForMappingEntities(): void
    {
        $writer = $this->createMock(EntityWriterInterface::class);
        $writer
            ->expects(static::once())
            ->method('sync')
            ->willReturnCallback(function D$operations) {
                static::assertCount(1, $operations);
                static::assertInstanceOf(SyncOperation::class$operations[0]);

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