@@ -59,6 +59,7 @@ class WordPressStubs
5959 public function __construct ($ vfs )
6060 {
6161 $ GLOBALS ['wp ' ] = $ this ;
62+ $ GLOBALS ['wpdb ' ] = $ this ;
6263 $ this ->vfs = $ vfs ;
6364 $ this ->addMethod ('add_action ' );
6465 $ this ->addMethod ('do_action ' );
@@ -90,6 +91,12 @@ public function __construct($vfs)
9091 $ this ->addMethod ('trailingslashit ' );
9192 $ this ->addMethod ('current_time ' );
9293 $ this ->addMethod ('wp_mkdir_p ' );
94+ $ this ->addMethod ('db_version ' );
95+ $ this ->addMethod ('wp_get_theme ' );
96+ $ this ->addMethod ('get_home_url ' );
97+ $ this ->addMethod ('get_locale ' );
98+ $ this ->addMethod ('wp_timezone_string ' );
99+ $ this ->addMethod ('update_option ' );
93100 $ this ->defaults ();
94101 $ this ->create_filesystem ();
95102 }
@@ -110,6 +117,11 @@ public function defaults()
110117 $ GLOBALS ['_wp_additional_image_sizes ' ] = array ();
111118 }
112119
120+ public function __call ($ method , $ args )
121+ {
122+ return $ this ->call ($ method , $ args );
123+ }
124+
113125 public function call ($ method , $ args )
114126 {
115127 $ mocks = new WordPressMocks ();
@@ -183,7 +195,7 @@ public function call($method, $args)
183195 } elseif ('is_admin ' === $ method ) {
184196 return true ;
185197 } elseif (method_exists ($ mocks , $ method )) {
186- return $ mocks-> $ method( $ args[ 0 ] );
198+ return call_user_func_array ( array ( $ mocks, $ method), $ args );
187199 }
188200 }
189201
@@ -348,7 +360,8 @@ public static function assertHook($hookname, $expected_args = null)
348360 }
349361}
350362
351- class WordPressMocks {
363+ class WordPressMocks
364+ {
352365 /**
353366 * Mocked function for https://developer.wordpress.org/reference/functions/trailingslashit/
354367 *
@@ -358,14 +371,15 @@ public function trailingslashit($value)
358371 {
359372 return $ value . '/ ' ;
360373 }
361-
374+
362375 /**
363376 * Mocked function for https://developer.wordpress.org/reference/functions/current_time/
364377 *
365378 * @return int|string
366379 */
367- public function current_time () {
368- $ dt = new DateTime ( 'now ' );
380+ public function current_time ()
381+ {
382+ $ dt = new DateTime ('now ' );
369383 return $ dt ->format ('Y-m-d H:i:s ' );
370384 }
371385
@@ -374,8 +388,71 @@ public function current_time() {
374388 *
375389 * @return bool
376390 */
377- public function wp_mkdir_p ( $ dir ) {
378- mkdir ( $ dir , 0755 , true );
391+ public function wp_mkdir_p ($ dir )
392+ {
393+ mkdir ($ dir , 0755 , true );
394+ }
395+
396+ /**
397+ * https://developer.wordpress.org/reference/classes/wpdb/db_version/
398+ *
399+ * @return string|null database version
400+ */
401+ public function db_version ()
402+ {
403+ return 'mysqlv ' ;
404+ }
405+
406+ /**
407+ * https://developer.wordpress.org/reference/classes/wpdb/db_version/
408+ *
409+ * @return string|null database version
410+ */
411+ public function wp_get_theme ()
412+ {
413+ return new class {
414+ function get ($ val )
415+ {
416+ return $ val ;
417+ }
418+ };
419+ }
420+
421+ /**
422+ * https://developer.wordpress.org/reference/classes/wpdb/db_version/
423+ *
424+ * @return string|null database version
425+ */
426+ public function get_home_url ()
427+ {
428+ return 'http://localhost ' ;
429+ }
430+
431+ /**
432+ * https://developer.wordpress.org/reference/classes/wpdb/db_version/
433+ *
434+ * @return string|null database version
435+ */
436+ public function get_locale ()
437+ {
438+ return 'gb_GB ' ;
439+ }
440+ /**
441+ * https://developer.wordpress.org/reference/functions/wp_timezone_string/
442+ *
443+ * @return string|null database version
444+ */
445+ public function wp_timezone_string ()
446+ {
447+ return 'timezone ' ;
448+ }
449+ /**
450+ * https://developer.wordpress.org/reference/functions/wp_timezone_string/
451+ *
452+ * @return void
453+ */
454+ public function update_option ()
455+ {
379456 }
380457}
381458
0 commit comments