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 12
12
namespace Symfony \Bridge \Doctrine \SchemaListener ;
13
13
14
14
use Doctrine \ORM \Tools \Event \GenerateSchemaEventArgs ;
15
- use Symfony \Component \Lock \Exception \InvalidArgumentException ;
16
15
use Symfony \Component \Lock \PersistingStoreInterface ;
17
16
use Symfony \Component \Lock \Store \DoctrineDbalStore ;
18
17
@@ -30,20 +29,12 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void
30
29
{
31
30
$ connection = $ event ->getEntityManager ()->getConnection ();
32
31
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 ;
44
35
}
45
36
46
- $ storesIterator -> next ( );
37
+ $ store -> configureSchema ( $ event -> getSchema (), $ this -> getIsSameDatabaseChecker ( $ connection ) );
47
38
}
48
39
}
49
40
}
Original file line number Diff line number Diff line change 17
17
use Doctrine \ORM \Tools \Event \GenerateSchemaEventArgs ;
18
18
use PHPUnit \Framework \TestCase ;
19
19
use Symfony \Bridge \Doctrine \SchemaListener \LockStoreSchemaListener ;
20
- use Symfony \Component \Lock \Exception \InvalidArgumentException ;
21
20
use Symfony \Component \Lock \Store \DoctrineDbalStore ;
22
21
23
22
class LockStoreSchemaListenerTest extends TestCase
@@ -37,23 +36,7 @@ public function testPostGenerateSchemaLockPdo()
37
36
->method ('configureSchema ' )
38
37
->with ($ schema , fn () => true );
39
38
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 )());
57
40
$ subscriber ->postGenerateSchema ($ event );
58
41
}
59
42
}
You can’t perform that action at this time.
0 commit comments