- in the Database:
- execute the ALTER TABLE MailingLists ENGINE = InnoDB; (add your table prefix as needed) database query
- in the IDE:
- open the /system/config.php file for editing
- append this to end of the file:
$_CONFIG['Databases'] = array( array( 'DBHost' => $_CONFIG['Database']['DBHost'], 'DBUser' => $_CONFIG['Database']['DBUser'], 'DBUserPassword' => $_CONFIG['Database']['DBUserPassword'], 'DBLoad' => 1, 'DBMaxLag' => 15, ), );
- save changes
- open the SampleUnitTest PHP class (somewhere inside /modules/custom/tests folder)
- add this code to that PHP class:
public function testDatabaseTransactions() { $this->Conn->Query('TRUNCATE TABLE ' . TABLE_PREFIX . 'MailingLists'); $count_sql = ' SELECT COUNT(*) FROM ' . TABLE_PREFIX . 'MailingLists'; $mailing_list_count_before = $this->Conn->GetOne($count_sql); $this->assertEquals(0, $mailing_list_count_before); $this->Conn->Query('begin'); $this->Conn->doInsert(array('Subject' => 'test'), TABLE_PREFIX . 'MailingLists'); $mailing_list_count_in_transaction = $this->Conn->GetOne($count_sql); $this->assertEquals(1, $mailing_list_count_in_transaction); $this->Conn->Query('rollback'); $mailing_list_count_after_rollback = $this->Conn->GetOne($count_sql); $this->assertEquals(0, $mailing_list_count_after_rollback); }
- save changes
- in CLI:
- run the vendor/bin/phpunit -c tools/build/inc/custom_phpunit.xml --filter testDatabaseTransactions command (prefix that command with a needed php binary version, e.g. php56)
- confirm, that test passed