Skip to content

Commit c1c90e8

Browse files
committed
Add special case for PHP 5.6 support
1 parent 7eb1fb0 commit c1c90e8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/UtilsTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,9 +799,17 @@ public function test_esc_like( $input, $expected ) {
799799
*/
800800
public function test_esc_like_with_wpdb( $input, $expected ) {
801801
global $wpdb;
802-
$wpdb = $this->getMockBuilder( 'stdClass' )
803-
->addMethods( [ 'esc_like' ] )
804-
->getMock();
802+
$wpdb = $this->getMockBuilder( 'stdClass' );
803+
804+
// Handle different PHPUnit versions (5.7 for PHP 5.6 vs newer versions)
805+
// This can be simplified if we drop support for PHP 5.6.
806+
if ( method_exists( $wpdb, 'addMethods' ) ) {
807+
$wpdb = $wpdb->addMethods( [ 'esc_like' ] );
808+
} else {
809+
$wpdb = $wpdb->setMethods( [ 'esc_like' ] );
810+
}
811+
812+
$wpdb = $wpdb->getMock();
805813
$wpdb->method( 'esc_like' )
806814
->willReturn( addcslashes( $input, '_%\\' ) );
807815
$this->assertEquals( $expected, Utils\esc_like( $input ) );

0 commit comments

Comments
 (0)