-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #58528 [DoctrineBridge] Add integration test for RememberMe wit…
…h postgres connection (GromNaN) This PR was merged into the 5.4 branch. Discussion ---------- [DoctrineBridge] Add integration test for RememberMe with postgres connection | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Related to - #27314 - #58523 Commits ------- ca417c0446 Add integration test for RememberMe with pg connection
- Loading branch information
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Tests/Security/RememberMe/DoctrineTokenProviderPostgresTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Symfony\Bridge\Doctrine\Tests\Security\RememberMe; | ||
|
||
use Doctrine\DBAL\Configuration; | ||
use Doctrine\DBAL\DriverManager; | ||
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory; | ||
use Doctrine\ORM\ORMSetup; | ||
use Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider; | ||
|
||
/** | ||
* @requires extension pdo_pgsql | ||
* @group integration | ||
*/ | ||
class DoctrineTokenProviderPostgresTest extends DoctrineTokenProviderTest | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
if (!getenv('POSTGRES_HOST')) { | ||
self::markTestSkipped('Missing POSTGRES_HOST env variable'); | ||
} | ||
} | ||
|
||
protected function bootstrapProvider() | ||
{ | ||
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration(); | ||
if (class_exists(DefaultSchemaManagerFactory::class)) { | ||
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory()); | ||
} | ||
|
||
$connection = DriverManager::getConnection([ | ||
'driver' => 'pdo_pgsql', | ||
'host' => getenv('POSTGRES_HOST'), | ||
'user' => 'postgres', | ||
'password' => 'password', | ||
], $config); | ||
$connection->{method_exists($connection, 'executeStatement') ? 'executeStatement' : 'executeUpdate'}(<<<'SQL' | ||
DROP TABLE IF EXISTS rememberme_token; | ||
SQL | ||
); | ||
|
||
$connection->{method_exists($connection, 'executeStatement') ? 'executeStatement' : 'executeUpdate'}(<<<'SQL' | ||
CREATE TABLE rememberme_token ( | ||
series CHAR(88) UNIQUE PRIMARY KEY NOT NULL, | ||
value VARCHAR(88) NOT NULL, -- CHAR(88) adds spaces at the end | ||
lastUsed TIMESTAMP NOT NULL, | ||
class VARCHAR(100) NOT NULL, | ||
username VARCHAR(200) NOT NULL | ||
); | ||
SQL | ||
); | ||
|
||
return new DoctrineTokenProvider($connection); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters