Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum committed Nov 26, 2024
1 parent a58a8b9 commit d2679d1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/php/TestQueryLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,30 @@ public function testIsQueryErrorWithStatusCode( $expected, $status_code ) {
$this->assertSame( $expected, $method->invokeArgs( $query_logger, [ $query ] ) );
}

/**
* Test the ep_disable_query_logging filter
*
* @group queryLogger
*/
public function testEpDisableQueryLoggingFilter() {
$query_logger = $this->getMockBuilder( QueryLogger::class )
->setMethods( [ 'add_query_log' ] )
->getMock();

add_filter( 'ep_disable_query_logging', '__return_true' );

$query_logger->add_query_log( [ 'query' => 'test' ] );

$class = new \ReflectionClass( $query_logger );

Check warning on line 523 in tests/php/TestQueryLogger.php

View workflow job for this annotation

GitHub Actions / PHP Lint

Equals sign not aligned with surrounding assignments; expected 4 spaces but found 2 spaces
$property = $class->getProperty( 'queries' );
$property->setAccessible( true );
$queries = $property->getValue( $query_logger );

$this->assertEmpty( $queries );

remove_filter( 'ep_disable_query_logging', '__return_true' );
}

/**
* Data provider for the testMaybeLogDeleteIndex method
*
Expand Down

0 comments on commit d2679d1

Please sign in to comment.