Changeset 44902 for trunk/tests/phpunit/includes/abstract-testcase.php
- Timestamp:
- 03/15/2019 12:01:15 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r44823 r44902 47 47 } 48 48 49 /** 50 * Retrieves the name of the class the static method is called in. 51 * 52 * @return string The class name. 53 */ 49 54 public static function get_called_class() { 50 55 if ( function_exists( 'get_called_class' ) ) { … … 62 67 } 63 68 69 /** 70 * Runs the routine before setting up all tests. 71 */ 64 72 public static function setUpBeforeClass() { 65 73 global $wpdb; … … 83 91 } 84 92 93 /** 94 * Runs the routine after all tests have been run. 95 */ 85 96 public static function tearDownAfterClass() { 86 97 parent::tearDownAfterClass(); … … 100 111 } 101 112 113 /** 114 * Runs the routine before each test is executed. 115 */ 102 116 public function setUp() { 103 117 set_time_limit( 0 ); … … 166 180 } 167 181 182 /** 183 * Cleans the global scope (e.g `$_GET` and `$_POST`). 184 */ 168 185 public function clean_up_global_scope() { 169 186 $_GET = array(); … … 270 287 * @global array $wp_current_filter 271 288 * @global array $wp_filter 272 * @return void273 289 */ 274 290 protected function _backup_hooks() { … … 290 306 * @global array $wp_current_filter 291 307 * @global array $wp_filter 292 * @return void293 308 */ 294 309 protected function _restore_hooks() { … … 307 322 } 308 323 324 /** 325 * Flushes the WordPress object cache. 326 */ 309 327 public static function flush_cache() { 310 328 global $wp_object_cache; … … 342 360 } 343 361 362 /** 363 * Starts a database transaction. 364 */ 344 365 public function start_transaction() { 345 366 global $wpdb; … … 360 381 } 361 382 383 /** 384 * Replaces the `CREATE TABLE` statement with a `CREATE TEMPORARY TABLE` statement. 385 * 386 * @param string $query The query to replace the statement for. 387 * @return string The altered query. 388 */ 362 389 public function _create_temporary_tables( $query ) { 363 390 if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) { … … 367 394 } 368 395 396 /** 397 * Replaces the `DROP TABLE` statement with a `DROP TEMPORARY TABLE` statement. 398 * 399 * @param string $query The query to replace the statement for. 400 * @return string The altered query. 401 */ 369 402 public function _drop_temporary_tables( $query ) { 370 403 if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) { … … 374 407 } 375 408 409 /** 410 * Retrieves the `wp_die()` handler. 411 * 412 * @param callable $handler The current die handler. 413 * @return callable The test die handler. 414 */ 376 415 public function get_wp_die_handler( $handler ) { 377 416 return array( $this, 'wp_die_handler' ); 378 417 } 379 418 419 /** 420 * Throws an exception when called. 421 * 422 * @throws WPDieException Exception containing the message. 423 * 424 * @param string $message The `wp_die()` message. 425 */ 380 426 public function wp_die_handler( $message ) { 381 427 if ( ! is_scalar( $message ) ) { … … 386 432 } 387 433 434 /** 435 * Sets up the expectations for testing a deprecated call. 436 */ 388 437 public function expectDeprecated() { 389 438 $annotations = $this->getAnnotations(); … … 406 455 } 407 456 457 /** 458 * Handles a deprecated expectation. 459 * 460 * The DocBlock should contain `@expectedDeprecated` to trigger this. 461 */ 408 462 public function expectedDeprecated() { 409 463 $errors = array(); … … 494 548 } 495 549 550 /** 551 * Adds a deprecated function to the list of caught deprecated calls. 552 * 553 * @param string $function The deprecated function. 554 */ 496 555 public function deprecated_function_run( $function ) { 497 556 if ( ! in_array( $function, $this->caught_deprecated ) ) { … … 500 559 } 501 560 561 /** 562 * Adds a function called in a wrong way to the list of `_doing_it_wrong()` calls. 563 * 564 * @param string $function The function to add. 565 */ 502 566 public function doing_it_wrong_run( $function ) { 503 567 if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) { … … 506 570 } 507 571 572 /** 573 * Asserts that the given value is an instance of WP_Error. 574 * 575 * @param mixed $actual The value to check. 576 * @param string $message Optional. Message to display when the assertion fails. 577 */ 508 578 public function assertWPError( $actual, $message = '' ) { 509 579 $this->assertInstanceOf( 'WP_Error', $actual, $message ); 510 580 } 511 581 582 /** 583 * Asserts that the given value is not an instance of WP_Error. 584 * 585 * @param mixed $actual The value to check. 586 * @param string $message Optional. Message to display when the assertion fails. 587 */ 512 588 public function assertNotWPError( $actual, $message = '' ) { 513 589 if ( is_wp_error( $actual ) && '' === $message ) { … … 517 593 } 518 594 595 596 /** 597 * Asserts that the given value is an instance of IXR_Error. 598 * 599 * @param mixed $actual The value to check. 600 * @param string $message Optional. Message to display when the assertion fails. 601 */ 519 602 public function assertIXRError( $actual, $message = '' ) { 520 603 $this->assertInstanceOf( 'IXR_Error', $actual, $message ); 521 604 } 522 605 606 /** 607 * Asserts that the given value is not an instance of IXR_Error. 608 * 609 * @param mixed $actual The value to check. 610 * @param string $message Optional. Message to display when the assertion fails. 611 */ 523 612 public function assertNotIXRError( $actual, $message = '' ) { 524 613 if ( $actual instanceof IXR_Error && '' === $message ) { … … 528 617 } 529 618 619 /** 620 * Asserts that the given fields are present in the given object. 621 * 622 * @param object $object The object to check. 623 * @param array $fields The fields to check. 624 */ 530 625 public function assertEqualFields( $object, $fields ) { 531 626 foreach ( $fields as $field_name => $field_value ) { … … 536 631 } 537 632 633 /** 634 * Asserts that two values are equal, with whitespace differences discarded. 635 * 636 * @param string $expected The expected value. 637 * @param string $actual The actual value. 638 */ 538 639 public function assertDiscardWhitespace( $expected, $actual ) { 539 640 $this->assertEquals( preg_replace( '/\s*/', '', $expected ), preg_replace( '/\s*/', '', $actual ) ); … … 761 862 * This method defines the constants after including files. 762 863 * 763 * @param Text_Template $template 864 * @param Text_Template $template The template to prepare. 764 865 */ 765 866 public function prepareTemplate( Text_Template $template ) { … … 919 1020 * 920 1021 * @param string $dir Path to the directory to scan. 921 *922 1022 * @return array List of file paths. 923 1023 */ … … 999 1099 * 1000 1100 * @param string $microtime Time string generated by `microtime()`. 1001 *1002 1101 * @return float `microtime()` output as a float. 1003 1102 */ … … 1013 1112 * 1014 1113 * @param int $user_id User ID. 1015 *1016 1114 * @return bool True if the user was deleted. 1017 1115 */ … … 1048 1146 * @param array $upload Array of information about the uploaded file, provided by wp_upload_bits(). 1049 1147 * @param int $parent_post_id Optional. Parent post ID. 1050 *1051 1148 * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure. 1052 1149 */ … … 1085 1182 * @param int $post_id Post ID. 1086 1183 * @param string $date Post date, in the format YYYY-MM-DD HH:MM:SS. 1087 *1088 1184 * @return int|false 1 on success, or false on error. 1089 1185 */
Note: See TracChangeset
for help on using the changeset viewer.