Skip to content

Commit

Permalink
relax mock class name matching
Browse files Browse the repository at this point in the history
Instead of performing some fuzzy matching on the automatically generated mock
name (the pattern varies between different PHPUnit versions) we can simply
use the actual exact class name.
  • Loading branch information
xabbuh committed Sep 25, 2024
1 parent 6682a40 commit e3f3cd6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Tests/Caster/DoctrineCasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public function testCastPersistentCollection()
{
$classMetadata = new ClassMetadata(__CLASS__);

$collection = new PersistentCollection($this->createMock(EntityManagerInterface::class), $classMetadata, new ArrayCollection(['test']));
$entityManager = $this->createMock(EntityManagerInterface::class);
$entityManagerClass = $entityManager::class;
$collection = new PersistentCollection($entityManager, $classMetadata, new ArrayCollection(['test']));

if (property_exists(PersistentCollection::class, 'isDirty')) {
// Collections >= 2
Expand All @@ -38,7 +40,7 @@ public function testCastPersistentCollection()
%A
-backRefFieldName: null
-isDirty: false
-em: Mock_EntityManagerInterface_%s { …3}
-em: $entityManagerClass { …3}
-typeClass: Doctrine\ORM\Mapping\ClassMetadata { …}
%A
EODUMP;
Expand All @@ -47,7 +49,7 @@ public function testCastPersistentCollection()
$expected = <<<EODUMP
Doctrine\ORM\PersistentCollection {
%A
-em: Mock_EntityManagerInterface_%s { …3}
-em: $entityManagerClass { …3}
-backRefFieldName: null
-typeClass: Doctrine\ORM\Mapping\ClassMetadata { …}
%A
Expand Down

0 comments on commit e3f3cd6

Please sign in to comment.