Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
--health-timeout 5s
--health-retries 5
postgres:
image: postgres
image: postgres:16.4
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: codeception_test
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"codeception/codeception": "*@dev"
},
"require-dev": {
"behat/gherkin": "~4.10.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gherking version has to be forced because of Codeception/Codeception#6833

"squizlabs/php_codesniffer": "*"
},
"conflict": {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
- "3306:3306"

postgres:
image: postgres
image: postgres:16.4
environment:
POSTGRES_PASSWORD: codeception
POSTGRES_DB: codeception
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Lib/Driver/PostgreSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function getPrimaryKey(string $tableName): array
FROM pg_index i
JOIN pg_attribute a ON a.attrelid = i.indrelid
AND a.attnum = ANY(i.indkey)
WHERE i.indrelid = '\"{$tableName}\"'::regclass
WHERE i.indrelid = '" . $this->getQuotedName($tableName) . "'::regclass
AND i.indisprimary";
$stmt = $this->executeQuery($query, []);
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
Expand Down
26 changes: 17 additions & 9 deletions tests/unit/Codeception/Module/Db/PostgreSqlDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ public function getConfig(): array
$this->markTestSkipped();
}

$host = getenv('PG_HOST') ?: 'localhost';
$user = getenv('PG_USER') ?: 'postgres';
$host = getenv('PG_HOST') ?: 'localhost';
$user = getenv('PG_USER') ?: 'postgres';
$password = getenv('PG_PASSWORD') ?: null;
$database = getenv('PG_DB') ?: 'codeception_test';
$dsn = getenv('PG_DSN') ?: 'pgsql:host=' . $host . ';dbname=' . $database;
$dsn = getenv('PG_DSN') ?: 'pgsql:host=' . $host . ';dbname=' . $database;

return [
'dsn' => $dsn,
'user' => $user,
'password' => $password,
'dump' => 'tests/data/dumps/postgres.sql',
'dsn' => $dsn,
'user' => $user,
'password' => $password,
'dump' => 'tests/data/dumps/postgres.sql',
'reconnect' => true,
'cleanup' => true,
'populate' => true
'cleanup' => true,
'populate' => true,
];
}

Expand All @@ -39,4 +39,12 @@ public function testHaveInDatabaseWithUppercaseTableName()
$testData = ['Status' => 'test'];
$this->module->haveInDatabase('NoPk', $testData);
}

public function testHaveInDatabaseWithAnotherSchema()
{
$userId = $this->module->haveInDatabase('anotherschema.users', ['name' => 'anotherschema', 'email' => 'anotherschema@test.com']);
$this->assertIsInt($userId);

$this->module->seeInDatabase('anotherschema.users', ['name' => 'anotherschema', 'email' => 'anotherschema@test.com']);
}
}