Skip to content

Commit

Permalink
refactor: move to AbstractHydratorTest
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Apr 22, 2024
1 parent 2f1fb76 commit 5a9d7f8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 76 deletions.
76 changes: 0 additions & 76 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH11101Test.php

This file was deleted.

30 changes: 30 additions & 0 deletions tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Tests\Models\Hydration\SimpleEntity;
use Doctrine\Tests\OrmFunctionalTestCase;
use PHPUnit\Framework\MockObject\MockObject;

Expand Down Expand Up @@ -154,4 +155,33 @@ public function testHydrateAllClearsAllAttachedListenersEvenOnError(): void
$this->expectException(ORMException::class);
$this->hydrator->hydrateAll($this->mockResult, $this->mockResultMapping);
}

public function testToIterableIfYieldAndBreakBeforeFinish(): void
{
$this->setUpEntitySchema([SimpleEntity::class]);

$entity1 = new SimpleEntity();
$this->_em->persist($entity1);
$entity2 = new SimpleEntity();
$this->_em->persist($entity2);

$this->_em->flush();
$this->_em->clear();

$evm = $this->_em->getEventManager();

$q = $this->_em->createQuery('SELECT u.id FROM ' . SimpleEntity::class . ' u')->setMaxResults(2);

// select two entity, but do no iterate
$q->toIterable();
self::assertCount(0, $evm->getListeners(Events::onClear));

// select two entity, but abort after first record
foreach ($q->toIterable() as $result) {
self::assertCount(1, $evm->getListeners(Events::onClear));
break;
}

self::assertCount(0, $evm->getListeners(Events::onClear));
}
}

0 comments on commit 5a9d7f8

Please sign in to comment.