Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
PHP 7.4 Compatibility
Browse files Browse the repository at this point in the history
- TestCase: Check if `$this->last_modifying_query` is not empty
- Database:
-- Point to the right Log class
-- Update the `getLastModifyingQuery()` return doc
  • Loading branch information
felipeelia committed Jan 20, 2020
1 parent 3857611 commit d1e3fd5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/classes/PHPUnit/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace WPAcceptance\PHPUnit;

use WPAcceptance\EnvironmentFactory;
use WPAcceptance\Log;

/**
* Database trait
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/classes/PHPUnit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down

0 comments on commit d1e3fd5

Please sign in to comment.