-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
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
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,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PeachySQL\Test\Pgsql; | ||
|
||
use PDO; | ||
use PeachySQL\PeachySql; | ||
use PeachySQL\Test\DbTestCase; | ||
use PeachySQL\Test\src\App; | ||
|
||
/** | ||
* @group pgsql | ||
*/ | ||
class PgsqlDbTest extends DbTestCase | ||
{ | ||
private static ?PeachySql $db = null; | ||
|
||
protected function getExpectedBadSyntaxCode(): int | ||
{ | ||
return 7; | ||
} | ||
|
||
protected function getExpectedBadSyntaxError(): string | ||
{ | ||
return 'syntax error'; | ||
} | ||
|
||
protected function getExpectedBadSqlState(): string | ||
{ | ||
return '42601'; | ||
} | ||
|
||
public static function dbProvider(): PeachySql | ||
{ | ||
if (!self::$db) { | ||
$c = App::$config; | ||
$dbName = getenv('POSTGRES_HOST') !== false ? 'postgres' : 'PeachySQL'; | ||
|
||
$pdo = new PDO($c->getPgsqlDsn($dbName), $c->getPgsqlUser(), $c->getPgsqlPassword(), [ | ||
PDO::ATTR_EMULATE_PREPARES => false, | ||
]); | ||
|
||
self::$db = new PeachySql($pdo); | ||
self::createTestTable(self::$db); | ||
} | ||
|
||
return self::$db; | ||
} | ||
|
||
private static function createTestTable(PeachySql $db): void | ||
{ | ||
$sql = " | ||
CREATE TABLE Users ( | ||
user_id SERIAL PRIMARY KEY, | ||
name VARCHAR(50) NOT NULL, | ||
dob DATE NOT NULL, | ||
weight REAL NOT NULL, | ||
is_disabled BOOLEAN NOT NULL, | ||
uuid bytea NULL | ||
)"; | ||
|
||
$db->query("DROP TABLE IF EXISTS Users"); | ||
$db->query($sql); | ||
} | ||
} |
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