diff --git a/SchemaListener/LockStoreSchemaListener.php b/SchemaListener/LockStoreSchemaListener.php index a85d159d..c4c3b0b7 100644 --- a/SchemaListener/LockStoreSchemaListener.php +++ b/SchemaListener/LockStoreSchemaListener.php @@ -12,7 +12,6 @@ namespace Symfony\Bridge\Doctrine\SchemaListener; use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; -use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\DoctrineDbalStore; @@ -30,20 +29,12 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void { $connection = $event->getEntityManager()->getConnection(); - $storesIterator = new \ArrayIterator($this->stores); - while ($storesIterator->valid()) { - try { - $store = $storesIterator->current(); - if (!$store instanceof DoctrineDbalStore) { - continue; - } - - $store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection)); - } catch (InvalidArgumentException) { - // no-op + foreach ($this->stores as $store) { + if (!$store instanceof DoctrineDbalStore) { + continue; } - $storesIterator->next(); + $store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection)); } } } diff --git a/Tests/SchemaListener/LockStoreSchemaListenerTest.php b/Tests/SchemaListener/LockStoreSchemaListenerTest.php index 6f23d680..6fd86a46 100644 --- a/Tests/SchemaListener/LockStoreSchemaListenerTest.php +++ b/Tests/SchemaListener/LockStoreSchemaListenerTest.php @@ -17,7 +17,6 @@ use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\SchemaListener\LockStoreSchemaListener; -use Symfony\Component\Lock\Exception\InvalidArgumentException; use Symfony\Component\Lock\Store\DoctrineDbalStore; class LockStoreSchemaListenerTest extends TestCase @@ -37,23 +36,7 @@ public function testPostGenerateSchemaLockPdo() ->method('configureSchema') ->with($schema, fn () => true); - $subscriber = new LockStoreSchemaListener([$lockStore]); - $subscriber->postGenerateSchema($event); - } - - public function testPostGenerateSchemaWithInvalidLockStore() - { - $entityManager = $this->createMock(EntityManagerInterface::class); - $entityManager->expects($this->once()) - ->method('getConnection') - ->willReturn($this->createMock(Connection::class)); - $event = new GenerateSchemaEventArgs($entityManager, new Schema()); - - $subscriber = new LockStoreSchemaListener((static function (): \Generator { - yield $this->createMock(DoctrineDbalStore::class); - - throw new InvalidArgumentException('Unsupported Connection'); - })()); + $subscriber = new LockStoreSchemaListener((static fn () => yield $lockStore)()); $subscriber->postGenerateSchema($event); } }