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
12 changes: 6 additions & 6 deletions tests/unit/Codeception/Module/Db/AbstractDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ public function testConnectionIsKeptForTheWholeSuite()
$this->module->_before($testCase1);
// Save these object instances IDs
$driverAndConn1 = [
$this->module->driver,
$this->module->dbh
$this->module->_getDriver(),
$this->module->_getDbh()
];
$this->module->_after($testCase1);

// Simulate a second test that runs
$this->module->_before($testCase2);

$driverAndConn2 = [
$this->module->driver,
$this->module->dbh
$this->module->_getDriver(),
$this->module->_getDbh()
];
$this->module->_after($testCase2);
$this->assertSame($driverAndConn2, $driverAndConn1);
Expand Down Expand Up @@ -157,8 +157,8 @@ public function testHaveInDatabaseWithCompositePrimaryKey()
{
$insertQuery = 'INSERT INTO composite_pk (group_id, id, status) VALUES (?, ?, ?)';
//this test checks that module does not delete columns by partial primary key
$this->module->driver->executeQuery($insertQuery, [1, 2, 'test']);
$this->module->driver->executeQuery($insertQuery, [2, 1, 'test2']);
$this->module->_getDriver()->executeQuery($insertQuery, [1, 2, 'test']);
$this->module->_getDriver()->executeQuery($insertQuery, [2, 1, 'test2']);

$testData = ['id' => 2, 'group_id' => 2, 'status' => 'test3'];
$this->module->haveInDatabase('composite_pk', $testData);
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Codeception/Module/Db/MySqlDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ public function testConnectionIsResetOnEveryTestWhenReconnectIsTrue()
// Simulate a test that runs
$this->module->_before($testCase1);

$connection1 = $this->module->dbh->query('SELECT CONNECTION_ID()')->fetch(PDO::FETCH_COLUMN);
$connection1 = $this->module->_getDbh()->query('SELECT CONNECTION_ID()')->fetch(PDO::FETCH_COLUMN);
$this->module->_after($testCase1);

// Simulate a second test that runs
$this->module->_before($testCase2);

$connection2 = $this->module->dbh->query('SELECT CONNECTION_ID()')->fetch(PDO::FETCH_COLUMN);
$connection2 = $this->module->_getDbh()->query('SELECT CONNECTION_ID()')->fetch(PDO::FETCH_COLUMN);
$this->module->_after($testCase2);
$this->module->_afterSuite();

$this->module->_setConfig(['reconnect' => true]);

$this->module->_before($testCase3);

$connection3 = $this->module->dbh->query('SELECT CONNECTION_ID()')->fetch(PDO::FETCH_COLUMN);
$connection3 = $this->module->_getDbh()->query('SELECT CONNECTION_ID()')->fetch(PDO::FETCH_COLUMN);
$this->module->_after($testCase3);

$this->assertSame($connection1, $connection2);
Expand All @@ -81,7 +81,7 @@ public function testInitialQueriesAreExecuted()
$this->module->_reconfigure($config);
$this->module->_before(Stub::makeEmpty(TestInterface::class));

$usedDatabaseName = $this->module->dbh->query('SELECT DATABASE();')->fetch(PDO::FETCH_COLUMN);
$usedDatabaseName = $this->module->_getDbh()->query('SELECT DATABASE();')->fetch(PDO::FETCH_COLUMN);

$this->assertSame($dbName, $usedDatabaseName);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/Codeception/Module/Db/SqliteDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ public function testConnectionIsResetOnEveryTestWhenReconnectIsTrue()
// Simulate a test that runs
$this->module->_before($testCase1);

$connection1 = spl_object_hash($this->module->dbh);
$connection1 = spl_object_hash($this->module->_getDbh());
$this->module->_after($testCase1);

// Simulate a second test that runs
$this->module->_before($testCase2);

$connection2 = spl_object_hash($this->module->dbh);
$connection2 = spl_object_hash($this->module->_getDbh());
$this->module->_after($testCase2);
$this->module->_afterSuite();

$this->module->_setConfig(['reconnect' => true]);

$this->module->_before($testCase3);

$connection3 = spl_object_hash($this->module->dbh);
$connection3 = spl_object_hash($this->module->_getDbh());
$this->module->_after($testCase3);

$this->assertSame($connection1, $connection2);
Expand Down