Changeset 44823 for trunk/tests/phpunit/includes/abstract-testcase.php
- Timestamp:
- 03/08/2019 08:51:32 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r44785 r44823 24 24 protected static $ignore_files; 25 25 26 function __isset( $name ) {26 public function __isset( $name ) { 27 27 return 'factory' === $name; 28 28 } 29 29 30 function __get( $name ) {30 public function __get( $name ) { 31 31 if ( 'factory' === $name ) { 32 32 return self::factory(); … … 100 100 } 101 101 102 function setUp() {102 public function setUp() { 103 103 set_time_limit( 0 ); 104 104 … … 140 140 * After a test method runs, reset any state in WordPress the test method might have changed. 141 141 */ 142 function tearDown() {142 public function tearDown() { 143 143 global $wpdb, $wp_query, $wp; 144 144 $wpdb->query( 'ROLLBACK' ); … … 166 166 } 167 167 168 function clean_up_global_scope() {168 public function clean_up_global_scope() { 169 169 $_GET = array(); 170 170 $_POST = array(); … … 307 307 } 308 308 309 static function flush_cache() {309 public static function flush_cache() { 310 310 global $wp_object_cache; 311 311 $wp_object_cache->group_ops = array(); … … 328 328 * @global array $wp_meta_keys 329 329 */ 330 function unregister_all_meta_keys() {330 public function unregister_all_meta_keys() { 331 331 global $wp_meta_keys; 332 332 if ( ! is_array( $wp_meta_keys ) ) { … … 342 342 } 343 343 344 function start_transaction() {344 public function start_transaction() { 345 345 global $wpdb; 346 346 $wpdb->query( 'SET autocommit = 0;' ); … … 360 360 } 361 361 362 function _create_temporary_tables( $query ) {362 public function _create_temporary_tables( $query ) { 363 363 if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) { 364 364 return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); … … 367 367 } 368 368 369 function _drop_temporary_tables( $query ) {369 public function _drop_temporary_tables( $query ) { 370 370 if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) { 371 371 return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); … … 374 374 } 375 375 376 function get_wp_die_handler( $handler ) {376 public function get_wp_die_handler( $handler ) { 377 377 return array( $this, 'wp_die_handler' ); 378 378 } 379 379 380 function wp_die_handler( $message ) {380 public function wp_die_handler( $message ) { 381 381 if ( ! is_scalar( $message ) ) { 382 382 $message = '0'; … … 386 386 } 387 387 388 function expectDeprecated() {388 public function expectDeprecated() { 389 389 $annotations = $this->getAnnotations(); 390 390 foreach ( array( 'class', 'method' ) as $depth ) { … … 406 406 } 407 407 408 function expectedDeprecated() {408 public function expectedDeprecated() { 409 409 $errors = array(); 410 410 … … 494 494 } 495 495 496 function deprecated_function_run( $function ) {496 public function deprecated_function_run( $function ) { 497 497 if ( ! in_array( $function, $this->caught_deprecated ) ) { 498 498 $this->caught_deprecated[] = $function; … … 500 500 } 501 501 502 function doing_it_wrong_run( $function ) {502 public function doing_it_wrong_run( $function ) { 503 503 if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) { 504 504 $this->caught_doing_it_wrong[] = $function; … … 506 506 } 507 507 508 function assertWPError( $actual, $message = '' ) {508 public function assertWPError( $actual, $message = '' ) { 509 509 $this->assertInstanceOf( 'WP_Error', $actual, $message ); 510 510 } 511 511 512 function assertNotWPError( $actual, $message = '' ) {512 public function assertNotWPError( $actual, $message = '' ) { 513 513 if ( is_wp_error( $actual ) && '' === $message ) { 514 514 $message = $actual->get_error_message(); … … 517 517 } 518 518 519 function assertIXRError( $actual, $message = '' ) {519 public function assertIXRError( $actual, $message = '' ) { 520 520 $this->assertInstanceOf( 'IXR_Error', $actual, $message ); 521 521 } 522 522 523 function assertNotIXRError( $actual, $message = '' ) {523 public function assertNotIXRError( $actual, $message = '' ) { 524 524 if ( $actual instanceof IXR_Error && '' === $message ) { 525 525 $message = $actual->message; … … 528 528 } 529 529 530 function assertEqualFields( $object, $fields ) {530 public function assertEqualFields( $object, $fields ) { 531 531 foreach ( $fields as $field_name => $field_value ) { 532 532 if ( $object->$field_name != $field_value ) { … … 536 536 } 537 537 538 function assertDiscardWhitespace( $expected, $actual ) {538 public function assertDiscardWhitespace( $expected, $actual ) { 539 539 $this->assertEquals( preg_replace( '/\s*/', '', $expected ), preg_replace( '/\s*/', '', $actual ) ); 540 540 } … … 548 548 * @param array $actual Array to check. 549 549 */ 550 function assertEqualSets( $expected, $actual ) {550 public function assertEqualSets( $expected, $actual ) { 551 551 sort( $expected ); 552 552 sort( $actual ); … … 562 562 * @param array $actual Array to check. 563 563 */ 564 function assertEqualSetsWithIndex( $expected, $actual ) {564 public function assertEqualSetsWithIndex( $expected, $actual ) { 565 565 ksort( $expected ); 566 566 ksort( $actual ); … … 575 575 * @param array $array Array to check. 576 576 */ 577 function assertNonEmptyMultidimensionalArray( $array ) {577 public function assertNonEmptyMultidimensionalArray( $array ) { 578 578 $this->assertTrue( is_array( $array ) ); 579 579 $this->assertNotEmpty( $array ); … … 598 598 * @param string $url The URL for the request. 599 599 */ 600 function go_to( $url ) {600 public function go_to( $url ) { 601 601 // note: the WP and WP_Query classes like to silently fetch parameters 602 602 // from all over the place (globals, GET, etc), which makes it tricky … … 704 704 * @param int $ticket_id Ticket number. 705 705 */ 706 function knownWPBug( $ticket_id ) {706 public function knownWPBug( $ticket_id ) { 707 707 if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) { 708 708 return; … … 722 722 * @param int $ticket_id Ticket number. 723 723 */ 724 function knownUTBug( $ticket_id ) {724 public function knownUTBug( $ticket_id ) { 725 725 return; 726 726 } … … 733 733 * @param int $ticket_id Ticket number. 734 734 */ 735 function knownPluginBug( $ticket_id ) {735 public function knownPluginBug( $ticket_id ) { 736 736 if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) { 737 737 return; … … 763 763 * @param Text_Template $template 764 764 */ 765 function prepareTemplate( Text_Template $template ) {765 public function prepareTemplate( Text_Template $template ) { 766 766 $template->setVar( array( 'constants' => '' ) ); 767 767 $template->setVar( array( 'wp_constants' => PHPUnit_Util_GlobalState::getConstantsAsString() ) ); … … 778 778 * @return string|bool Path on success, else false. 779 779 */ 780 function temp_filename() {780 public function temp_filename() { 781 781 $tmp_dir = ''; 782 782 $dirs = array( 'TMP', 'TMPDIR', 'TEMP' ); … … 806 806 * @param string $prop,... Any number of WP_Query properties that are expected to be true for the current request. 807 807 */ 808 function assertQueryTrue() {808 public function assertQueryTrue() { 809 809 global $wp_query; 810 810 $all = array( … … 873 873 * @param string $file File path. 874 874 */ 875 function unlink( $file ) {875 public function unlink( $file ) { 876 876 $exists = is_file( $file ); 877 877 if ( $exists && ! in_array( $file, self::$ignore_files ) ) { … … 890 890 * @param string $path Directory path. 891 891 */ 892 function rmdir( $path ) {892 public function rmdir( $path ) { 893 893 $files = $this->files_in_dir( $path ); 894 894 foreach ( $files as $file ) { … … 908 908 * called during `tearDown()` in tests, this will only delete files added during the previously run test. 909 909 */ 910 function remove_added_uploads() {910 public function remove_added_uploads() { 911 911 $uploads = wp_upload_dir(); 912 912 $this->rmdir( $uploads['basedir'] ); … … 922 922 * @return array List of file paths. 923 923 */ 924 function files_in_dir( $dir ) {924 public function files_in_dir( $dir ) { 925 925 $files = array(); 926 926 … … 943 943 * @return array List of file paths. 944 944 */ 945 function scan_user_uploads() {945 public function scan_user_uploads() { 946 946 static $files = array(); 947 947 if ( ! empty( $files ) ) { … … 961 961 * @param string $path Path to the directory to scan. 962 962 */ 963 function delete_folders( $path ) {963 public function delete_folders( $path ) { 964 964 $this->matched_dirs = array(); 965 965 if ( ! is_dir( $path ) ) { … … 984 984 * @param string $dir Path to the directory to scan. 985 985 */ 986 function scandir( $dir ) {986 public function scandir( $dir ) { 987 987 foreach ( scandir( $dir ) as $path ) { 988 988 if ( 0 !== strpos( $path, '.' ) && is_dir( $dir . '/' . $path ) ) { … … 1051 1051 * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure. 1052 1052 */ 1053 function _make_attachment( $upload, $parent_post_id = 0 ) {1053 public function _make_attachment( $upload, $parent_post_id = 0 ) { 1054 1054 $type = ''; 1055 1055 if ( ! empty( $upload['type'] ) ) {
Note: See TracChangeset
for help on using the changeset viewer.