diff --git a/src/classes/PHPUnit/Database.php b/src/classes/PHPUnit/Database.php index 4315377..9a6b97b 100644 --- a/src/classes/PHPUnit/Database.php +++ b/src/classes/PHPUnit/Database.php @@ -8,6 +8,7 @@ namespace WPAcceptance\PHPUnit; use WPAcceptance\EnvironmentFactory; +use WPAcceptance\Log; /** * Database trait @@ -17,7 +18,7 @@ trait Database { /** * Get the last INSERT, UPDATE, or DELETE that happened in the MySQL server * - * @return array + * @return array|null */ protected function getLastModifyingQuery() { $mysql = EnvironmentFactory::get()->getMySQLClient(); diff --git a/src/classes/PHPUnit/TestCase.php b/src/classes/PHPUnit/TestCase.php index 7c297e2..488000e 100644 --- a/src/classes/PHPUnit/TestCase.php +++ b/src/classes/PHPUnit/TestCase.php @@ -64,7 +64,7 @@ public function tearDown() { $new_last_modifying_query = $this->getLastModifyingQuery(); - if ( ! empty( $new_last_modifying_query ) && $new_last_modifying_query['event_time'] !== $this->last_modifying_query['event_time'] ) { + if ( ! empty( $this->last_modifying_query ) && ! empty( $new_last_modifying_query ) && $new_last_modifying_query['event_time'] !== $this->last_modifying_query['event_time'] ) { Log::instance()->write( 'Test modified the database (' . $this->getName() . ').', 1, 'warning' ); Log::instance()->write( 'Last query at ' . $new_last_modifying_query['event_time'] . ': ' . $new_last_modifying_query['argument'], 2 );