kbond /
porpaginas
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Zenstruck\Porpaginas\Tests\Doctrine; |
||||||
| 4 | |||||||
| 5 | use Zenstruck\Porpaginas\Tests\Doctrine\Fixtures\ORMEntity; |
||||||
| 6 | use Zenstruck\Porpaginas\Tests\ResultTest; |
||||||
| 7 | |||||||
| 8 | abstract class ORMResultTest extends ResultTest |
||||||
| 9 | { |
||||||
| 10 | use HasEntityManager; |
||||||
| 11 | |||||||
| 12 | /** |
||||||
| 13 | * @test |
||||||
| 14 | */ |
||||||
| 15 | public function detaches_entity_from_em_on_iterate(): void |
||||||
| 16 | { |
||||||
| 17 | $result = \iterator_to_array($this->createResultWithItems(2))[0]; |
||||||
| 18 | |||||||
| 19 | $this->assertFalse($this->em->contains($result)); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 20 | } |
||||||
| 21 | |||||||
| 22 | /** |
||||||
| 23 | * @test |
||||||
| 24 | */ |
||||||
| 25 | public function can_batch_update_results(): void |
||||||
| 26 | { |
||||||
| 27 | $result = $this->createResultWithItems(2); |
||||||
| 28 | $values = \array_map(static function(ORMEntity $entity) { return $entity->value; }, \iterator_to_array($result)); |
||||||
| 29 | |||||||
| 30 | $this->assertSame(['value 1', 'value 2'], $values); |
||||||
| 31 | |||||||
| 32 | $batchIterator = $result->batchProcessor(); |
||||||
|
0 ignored issues
–
show
The method
batchProcessor() does not exist on Zenstruck\Porpaginas\Result. It seems like you code against a sub-type of Zenstruck\Porpaginas\Result such as Zenstruck\Porpaginas\Doctrine\ORMQueryResult.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 33 | |||||||
| 34 | $this->assertCount(2, $batchIterator); |
||||||
| 35 | |||||||
| 36 | foreach ($batchIterator as $item) { |
||||||
| 37 | $item->value = 'new '.$item->value; |
||||||
| 38 | } |
||||||
| 39 | |||||||
| 40 | $values = \array_map( |
||||||
| 41 | static function(ORMEntity $entity) { return $entity->value; }, |
||||||
| 42 | $this->em->getRepository(ORMEntity::class)->findAll() |
||||||
| 43 | ); |
||||||
| 44 | |||||||
| 45 | $this->assertSame(['new value 1', 'new value 2'], $values); |
||||||
| 46 | } |
||||||
| 47 | |||||||
| 48 | /** |
||||||
| 49 | * @test |
||||||
| 50 | */ |
||||||
| 51 | public function can_batch_delete_results(): void |
||||||
| 52 | { |
||||||
| 53 | $result = $this->createResultWithItems(2); |
||||||
| 54 | |||||||
| 55 | $this->assertCount(2, $result); |
||||||
| 56 | |||||||
| 57 | $batchIterator = $result->batchProcessor(); |
||||||
| 58 | |||||||
| 59 | $this->assertCount(2, $batchIterator); |
||||||
| 60 | |||||||
| 61 | foreach ($batchIterator as $item) { |
||||||
| 62 | $this->em->remove($item); |
||||||
| 63 | } |
||||||
| 64 | |||||||
| 65 | $this->assertCount(0, $this->em->getRepository(ORMEntity::class)->findAll()); |
||||||
| 66 | } |
||||||
| 67 | |||||||
| 68 | protected function getExpectedValueAtPosition(int $position) |
||||||
| 69 | { |
||||||
| 70 | return new ORMEntity('value '.$position, $position); |
||||||
| 71 | } |
||||||
| 72 | } |
||||||
| 73 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.