Skip to content

Commit

Permalink
test: since php 8 PDO::rollback will act like php 7
Browse files Browse the repository at this point in the history
  • Loading branch information
hungtrinh committed Aug 13, 2023
1 parent d2df032 commit bd9707f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Zend/Db/Adapter/Pdo/MysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,28 @@ public function testSincePhp8WhenRollbackWithAnyImplicitCommitBeforeWillRaisePdo
$dbConnection->query('INSERT INTO MYTABLE(myname) VALUES ("1"),("2")');
$dbConnection->rollBack();
}

/**
* @requires PHP >= 8
* @runInSeparateProcess
*
* https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.pdo-mysql
*/
public function testSincePhp8WhenRollbackWithAnyImplicitCommitBeforeWithPatchCodeWillSilentErrorSamePhp7()
{
$implicitCommitStatement = 'CREATE TABLE MYTABLE( myname TEXT)'; //https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html
$dbConnection = $this->_db;
$dbConnection->query('DROP TABLE IF EXISTS MYTABLE');

$dbConnection->beginTransaction();
$dbConnection->query($implicitCommitStatement);
$dbConnection->query('INSERT INTO MYTABLE(myname) VALUES ("1"),("2")');
$dbConnection->rollBack();

$actual = $dbConnection->fetchOne('SELECT COUNT(*) FROM MYTABLE');
$expected = 2; //rollback does not effect.
$this->assertEquals($expected, $actual);
}
}

class ZendTest_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Mysql
Expand Down

0 comments on commit bd9707f

Please sign in to comment.