From: Aaron Schulz Date: Fri, 2 Sep 2016 16:57:40 +0000 (-0700) Subject: Run database-using tests in MySQL STRICT mode X-Git-Tag: 1.31.0-rc.0~5708^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=80899f4853f4d244c246d65196fa5d889872d81a;p=lhc%2Fweb%2Fwiklou.git Run database-using tests in MySQL STRICT mode Change-Id: Ib2873913102d7a7fcd84d1860725fb501cb41b64 --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 541ac11518..50b33905cc 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -477,6 +477,10 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { while ( $this->db->trxLevel() > 0 ) { $this->db->rollback( __METHOD__, 'flush' ); } + // Check for unsafe queries + if ( $this->db->getType() === 'mysql' ) { + $this->db->query( "SET sql_mode = 'STRICT_ALL_TABLES'" ); + } } DeferredUpdates::clearPendingUpdates(); @@ -495,7 +499,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } protected function tearDown() { - global $wgRequest; + global $wgRequest, $wgSQLMode; $status = ob_get_status(); if ( isset( $status['name'] ) && @@ -519,6 +523,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { while ( $this->db->trxLevel() > 0 ) { $this->db->rollback( __METHOD__, 'flush' ); } + if ( $this->db->getType() === 'mysql' ) { + $this->db->query( "SET sql_mode = " . $this->db->addQuotes( $wgSQLMode ) ); + } } // Restore mw globals