File tree Expand file tree Collapse file tree 2 files changed +5
-31
lines changed Expand file tree Collapse file tree 2 files changed +5
-31
lines changed Original file line number Diff line number Diff line change 1212namespace Symfony \Bridge \Doctrine \SchemaListener ;
1313
1414use Doctrine \ORM \Tools \Event \GenerateSchemaEventArgs ;
15- use Symfony \Component \Lock \Exception \InvalidArgumentException ;
1615use Symfony \Component \Lock \PersistingStoreInterface ;
1716use Symfony \Component \Lock \Store \DoctrineDbalStore ;
1817
@@ -30,20 +29,12 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void
3029 {
3130 $ connection = $ event ->getEntityManager ()->getConnection ();
3231
33- $ storesIterator = new \ArrayIterator ($ this ->stores );
34- while ($ storesIterator ->valid ()) {
35- try {
36- $ store = $ storesIterator ->current ();
37- if (!$ store instanceof DoctrineDbalStore) {
38- continue ;
39- }
40-
41- $ store ->configureSchema ($ event ->getSchema (), $ this ->getIsSameDatabaseChecker ($ connection ));
42- } catch (InvalidArgumentException ) {
43- // no-op
32+ foreach ($ this ->stores as $ store ) {
33+ if (!$ store instanceof DoctrineDbalStore) {
34+ continue ;
4435 }
4536
46- $ storesIterator -> next ( );
37+ $ store -> configureSchema ( $ event -> getSchema (), $ this -> getIsSameDatabaseChecker ( $ connection ) );
4738 }
4839 }
4940}
Original file line number Diff line number Diff line change 1717use Doctrine \ORM \Tools \Event \GenerateSchemaEventArgs ;
1818use PHPUnit \Framework \TestCase ;
1919use Symfony \Bridge \Doctrine \SchemaListener \LockStoreSchemaListener ;
20- use Symfony \Component \Lock \Exception \InvalidArgumentException ;
2120use Symfony \Component \Lock \Store \DoctrineDbalStore ;
2221
2322class LockStoreSchemaListenerTest extends TestCase
@@ -37,23 +36,7 @@ public function testPostGenerateSchemaLockPdo()
3736 ->method ('configureSchema ' )
3837 ->with ($ schema , fn () => true );
3938
40- $ subscriber = new LockStoreSchemaListener ([$ lockStore ]);
41- $ subscriber ->postGenerateSchema ($ event );
42- }
43-
44- public function testPostGenerateSchemaWithInvalidLockStore ()
45- {
46- $ entityManager = $ this ->createMock (EntityManagerInterface::class);
47- $ entityManager ->expects ($ this ->once ())
48- ->method ('getConnection ' )
49- ->willReturn ($ this ->createMock (Connection::class));
50- $ event = new GenerateSchemaEventArgs ($ entityManager , new Schema ());
51-
52- $ subscriber = new LockStoreSchemaListener ((static function (): \Generator {
53- yield $ this ->createMock (DoctrineDbalStore::class);
54-
55- throw new InvalidArgumentException ('Unsupported Connection ' );
56- })());
39+ $ subscriber = new LockStoreSchemaListener ((static fn () => yield $ lockStore )());
5740 $ subscriber ->postGenerateSchema ($ event );
5841 }
5942}
You can’t perform that action at this time.
0 commit comments