8000 [Http-Foundation] fix: test + coding standards · symfony/symfony@3cdc426 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3cdc426

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

File tree

8 files changed

+46
-15
lines changed

8 files changed

+46
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
final class PdoSessionHandlerSchemaSubscriber extends AbstractSchemaSubscriber
1818
{
19-
private array $pdoSessionHandlers;
19+
private iterable $pdoSessionHandlers;
2020

2121
/**
2222
* @param iterable<mixed, PdoSessionHandler> $pdoSessionHandlers
@@ -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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
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

1718
/**
1819
* @requires extension pdo_sqlite
20+
*
1921
* @group time-sensitive
2022
*/
2123
class PdoSessionHandlerTest extends TestCase
@@ -326,6 +328,38 @@ public function testUrlDsn($url, $expectedDsn, $expectedUser = null, $expectedPa
326328
}
327329
}
328330

331+
public function testConfigureSchemaDifferentDatabase()
332+
{
333+
$someFunction = function () { return false; };
334+
$schema = new Schema();
335+
336+
$pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
337+
$pdoSessionHandler->configureSchema($schema, $someFunction);
338+
$this->assertFalse($schema->hasTable('sessions'));
339+
}
340+
341+
public function testConfigureSchemaSameDatabase()
342+
{
343+
$someFunction = function () { return true; };
344+
$schema = new Schema();
345+
346+
$pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
347+
$pdoSessionHandler->configureSchema($schema, $someFunction);
348+
$this->assertTrue($schema->hasTable('sessions'));
349+
}
350+
351+
public function testConfigureSchemaTableExistsPdo()
352+
{
353+
$schema = new Schema();
354+
$schema->createTable('sessions');
355+
356+
$pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
357+
$someFunction = function () { return true; };
358+
$pdoSessionHandler->configureSchema($schema, $someFunction);
359+
$table = $schema->getTable('sessions');
360+
$this->assertEmpty($table->getColumns(), 'The table was not overwritten');
361+
}
362+
329363
public function provideUrlDsnPairs()
330364
{
331365
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)
0