File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff 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 ) );
You can’t perform that action at this time.
0 commit comments