Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8466778

Browse filesBrowse files
committed
Add integration test for RememberMe with pg connection
1 parent b6a5496 commit 8466778
Copy full SHA for 8466778

File tree

Expand file treeCollapse file tree

2 files changed

+55
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+55
-2
lines changed
+53Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Symfony\Bridge\Doctrine\Tests\Security\RememberMe;
4+
5+
use Doctrine\DBAL\Configuration;
6+
use Doctrine\DBAL\DriverManager;
7+
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
8+
use Doctrine\ORM\ORMSetup;
9+
use Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider;
10+
11+
/**
12+
* @requires extension pdo_pgsql
13+
* @group integration
14+
*/
15+
class DoctrineTokenProviderPostgresTest extends DoctrineTokenProviderTest
16+
{
17+
public static function setUpBeforeClass(): void
18+
{
19+
if (!getenv('POSTGRES_HOST')) {
20+
self::markTestSkipped('Missing POSTGRES_HOST env variable');
21+
}
22+
}
23+
24+
protected function bootstrapProvider()
25+
{
26+
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
27+
if (class_exists(DefaultSchemaManagerFactory::class)) {
28+
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
29+
}
30+
31+
$connection = DriverManager::getConnection([
32+
'driver' => 'pgsql',
33+
'host' => getenv('POSTGRES_HOST'),
34+
'user' => 'postgres',
35+
'password' => 'password',
36+
], $config);
37+
$connection->{method_exists($connection, 'executeStatement') ? 'executeStatement' : 'executeUpdate'}(<<<'SQL'
38+
DROP TABLE IF EXISTS rememberme_token;
39+
SQL);
40+
41+
$connection->{method_exists($connection, 'executeStatement') ? 'executeStatement' : 'executeUpdate'}(<<<'SQL'
42+
CREATE TABLE rememberme_token (
43+
series CHAR(88) UNIQUE PRIMARY KEY NOT NULL,
44+
value VARCHAR(88) NOT NULL, -- CHAR(88) adds spaces at the end
45+
lastUsed TIMESTAMP NOT NULL,
46+
class VARCHAR(100) NOT NULL,
47+
username VARCHAR(200) NOT NULL
48+
);
49+
SQL);
50+
51+
return new DoctrineTokenProvider($connection);
52+
}
53+
}

‎src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Security\RememberMe;
12+
namespace Symfony\Bridge\Doctrine\Tests\Security\RememberMe;
1313

1414
use Doctrine\DBAL\Configuration;
1515
use Doctrine\DBAL\DriverManager;
@@ -121,7 +121,7 @@ public function testVerifyOutdatedTokenAfterParallelRequestFailsAfter60Seconds()
121121
/**
122122
* @return DoctrineTokenProvider
123123
*/
124-
private function bootstrapProvider()
124+
protected function bootstrapProvider()
125125
{
126126
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
127127
if (class_exists(DefaultSchemaManagerFactory::class)) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.