Skip to content

Commit f95d882

Browse files
committed
[Http-Foundation] fix: test + coding standards
1 parent 3ba0401 commit f95d882

File tree

8 files changed

+44
-14
lines changed

8 files changed

+44
-14
lines changed

src/Symfony/Bridge/Doctrine/SchemaListener/PdoSessionHandlerSchemaSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void
3131
$connection = $event->getEntityManager()->getConnection();
3232

3333
foreach ($this->pdoSessionHandlers as $pdoSessionHandler) {
34-
$pdoSessionHandler->configureSchema($event->getSchema(), $connection, $this->getIsSameDatabaseChecker($connection));
34+
$pdoSessionHandler->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection));
3535
}
3636
}
3737
}

src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ public function updateExistingToken(PersistentTokenInterface $token, #[\Sensitiv
188188

189189
/**
190190
* Adds the Table to the Schema if "remember me" uses this Connection.
191-
*
192-
* @param \Closure $isSameDatabase
193191
*/
194192
public function configureSchema(Schema $schema, Connection $forConnection/* , \Closure $isSameDatabase */): void
195193
{

src/Symfony/Bridge/Doctrine/Tests/SchemaListener/PdoSessionHandlerSchemaSubscriberTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ public function testPostGenerateSchemaPdo()
3232
$event = new GenerateSchemaEventArgs($entityManager, $schema);
3333

3434
$pdoSessionHandler = $this->createMock(PdoSessionHandler::class);
35+
$someFunction = function() { return true; };
3536
$pdoSessionHandler->expects($this->once())
3637
->method('configureSchema')
37-
->with($schema, $dbalConnection);
38+
->with($schema, $someFunction);
3839

39-
$subscriber = new PdoSessionHandlerSchemaSubscriber($pdoSessionHandler);
40+
$subscriber = new PdoSessionHandlerSchemaSubscriber([$pdoSessionHandler]);
4041
$subscriber->postGenerateSchema($event);
4142
}
4243
}

src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ public function createTable(): void
9898
}
9999
}
100100

101-
/**
102-
* @param \Closure $isSameDatabase
103-
*/
104101
public function configureSchema(Schema $schema, Connection $forConnection/* , \Closure $isSameDatabase */): void
105102
{
106103
if ($schema->hasTable($this->table)) {

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function __construct(\PDO|string $pdoOrDsn = null, array $options = [])
179179
$this->ttl = $options['ttl'] ?? null;
180180
}
181181

182-
public function configureSchema(Schema $schema, Connection $connection, \Closure $isSameDatabase): void
182+
public function configureSchema(Schema $schema, \Closure $isSameDatabase): void
183183
{
184184
if ($schema->hasTable($this->table) || !$isSameDatabase($this->getConnection()->exec(...))) {
185185
return;

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
1313

14+
use Doctrine\DBAL\Schema\Schema;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
1617

@@ -326,6 +327,38 @@ public function testUrlDsn($url, $expectedDsn, $expectedUser = null, $expectedPa
326327
}
327328
}
328329

330+
public function testConfigureSchemaDifferentDatabase()
331+
{
332+
$someFunction = function() { return false; };
333+
$schema = new Schema();
334+
335+
$pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
336+
$pdoSessionHandler->configureSchema($schema, $someFunction);
337+
$this->assertFalse($schema->hasTable('sessions'));
338+
}
339+
340+
public function testConfigureSchemaSameDatabase()
341+
{
342+
$someFunction = function() { return true; };
343+
$schema = new Schema();
344+
345+
$pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
346+
$pdoSessionHandler->configureSchema($schema, $someFunction);
347+
$this->assertTrue($schema->hasTable('sessions'));
348+
}
349+
350+
public function testConfigureSchemaTableExistsPdo()
351+
{
352+
$schema = new Schema();
353+
$schema->createTable('sessions');
354+
355+
$pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
356+
$someFunction = function() { return true; };
357+
$pdoSessionHandler->configureSchema($schema, $someFunction);
358+
$table = $schema->getTable('sessions');
359+
$this->assertEmpty($table->getColumns(), 'The table was not overwritten');
360+
}
361+
329362
public function provideUrlDsnPairs()
330363
{
331364
yield ['mysql://localhost/test', 'mysql:host=localhost;dbname=test;'];

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,32 +408,35 @@ public function providePlatformSql(): iterable
408408
public function testConfigureSchema()
409409
{
410410
$driverConnection = $this->getDBALConnectionMock();
411+
$someFunction = function() { return true; };
411412
$schema = new Schema();
412413

413414
$connection = new Connection(['table_name' => 'queue_table'], $driverConnection);
414-
$connection->configureSchema($schema, $driverConnection);
415+
$connection->configureSchema($schema, $driverConnection, $someFunction);
415416
$this->assertTrue($schema->hasTable('queue_table'));
416417
}
417418

418419
public function testConfigureSchemaDifferentDbalConnection()
419420
{
420421
$driverConnection = $this->getDBALConnectionMock();
421422
$driverConnection2 = $this->getDBALConnectionMock();
423+
$someFunction = function() { return false; };
422424
$schema = new Schema();
423425

424426
$connection = new Connection([], $driverConnection);
425-
$connection->configureSchema($schema, $driverConnection2);
427+
$connection->configureSchema($schema, $driverConnection2, $someFunction);
426428
$this->assertFalse($schema->hasTable('messenger_messages'));
427429
}
428430

429431
public function testConfigureSchemaTableExists()
430432
{
431433
$driverConnection = $this->getDBALConnectionMock();
434+
$someFunction = function() { return true; };
432435
$schema = new Schema();
433436
$schema->createTable('messenger_messages');
434437

435438
$connection = new Connection([], $driverConnection);
436-
$connection->configureSchema($schema, $driverConnection);
439+
$connection->configureSchema($schema, $driverConnection, $someFunction);
437440
$table = $schema->getTable('messenger_messages');
438441
$this->assertEmpty($table->getColumns(), 'The table was not overwritten');
439442
}

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransport.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ public function setup(): void
7979

8080
/**
8181
* Adds the Table to the Schema if this transport uses this connection.
82-
*
83-
* @param \Closure $isSameDatabase
8482
*/
8583
public function configureSchema(Schema $schema, DbalConnection $forConnection/* , \Closure $isSameDatabase */): void
8684
{

0 commit comments

Comments
 (0)