Skip to content

Commit

Permalink
Merge branch '6.4' into 7.1
Browse files Browse the repository at this point in the history
* 6.4:
  [DoctrineBridge] Fix the `LockStoreSchemaListener`
  add German translations for the Week constraint messages
  sync Week constraint messages translations
  [Validator] Add `D` regex modifier in relevant validators
  [Validator] Add French translation for the `Week` constraint
  skip transient Redis integration tests on AppVeyor
  reject malformed URLs with a meaningful exception
  [Mime] Add tests on constraints
  • Loading branch information
nicolas-grekas committed Aug 13, 2024
2 parents 1797031 + 3c7a50b commit 5c31b27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
17 changes: 4 additions & 13 deletions SchemaListener/LockStoreSchemaListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
}
}
}
19 changes: 1 addition & 18 deletions Tests/SchemaListener/LockStoreSchemaListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}

0 comments on commit 5c31b27

Please sign in to comment.