Changeset 53942
- Timestamp:
- 08/25/2022 03:34:24 PM (2 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/actions.php
r53808 r53942 7 7 */ 8 8 class Tests_Actions extends WP_UnitTestCase { 9 10 /** 11 * Flag to keep track whether a certain filter has been applied. 12 * 13 * Used in the `test_doing_filter_real()` test method. 14 * 15 * @var bool 16 */ 17 private $apply_testing_filter = false; 18 19 /** 20 * Flag to keep track whether a certain filter has been applied. 21 * 22 * Used in the `test_doing_filter_real()` test method. 23 * 24 * @var bool 25 */ 26 private $apply_testing_nested_filter = false; 27 28 /** 29 * Clean up after each test. 30 */ 31 public function tear_down() { 32 // Make sure potentially changed properties are reverted to their default value. 33 $this->apply_testing_filter = false; 34 $this->apply_testing_nested_filter = false; 35 36 parent::tear_down(); 37 } 9 38 10 39 /** -
trunk/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php
r51462 r53942 17 17 */ 18 18 class Tests_Admin_wpPrivacyRequestsTable extends WP_UnitTestCase { 19 20 /** 21 * Temporary storage for SQL to allow a filter to access it. 22 * 23 * Used in the `test_columns_should_be_sortable()` test method. 24 * 25 * @var string 26 */ 27 private $sql; 28 29 /** 30 * Clean up after each test. 31 */ 32 public function tear_down() { 33 unset( $this->sql ); 34 35 parent::tear_down(); 36 } 37 19 38 /** 20 39 * Get instance for mocked class. -
trunk/tests/phpunit/tests/comment/query.php
r53863 r53942 10 10 protected $comment_id; 11 11 12 /** 13 * Temporary storage for comment exclusions to allow a filter to access these. 14 * 15 * Used in the following tests: 16 * - `test_comment_clauses_prepend_callback_should_be_respected_when_filling_descendants()` 17 * - `test_comment_clauses_append_callback_should_be_respected_when_filling_descendants()` 18 * 19 * @var array 20 */ 21 private $to_exclude; 22 12 23 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 13 24 self::$post_id = $factory->post->create(); 25 } 26 27 public function tear_down() { 28 unset( $this->to_exclude ); 29 parent::tear_down(); 14 30 } 15 31 … … 4302 4318 remove_filter( 'comments_clauses', array( $this, 'prepend_exclusions' ) ); 4303 4319 4304 unset( $this->to_exclude );4305 4306 4320 $this->assertEqualSets( array( $top_level_0, $child1_of_0, $top_level_comments[0], $top_level_comments[2] ), wp_list_pluck( $q->comments, 'comment_ID' ) ); 4307 4321 } … … 4360 4374 ); 4361 4375 remove_filter( 'comments_clauses', array( $this, 'append_exclusions' ) ); 4362 4363 unset( $this->to_exclude );4364 4376 4365 4377 $this->assertEqualSets( array( $top_level_0, $child1_of_0, $top_level_comments[0], $top_level_comments[2] ), wp_list_pluck( $q->comments, 'comment_ID' ) ); -
trunk/tests/phpunit/tests/hooks/addFilter.php
r53804 r53942 12 12 public $hook; 13 13 14 /** 15 * Temporary storage for action output. 16 * 17 * Used in the following tests: 18 * - `test_remove_and_add_action()` 19 * - `test_remove_and_add_last_action()` 20 * - `test_remove_and_recurse_and_add_action()` 21 * 22 * @var array 23 */ 24 private $action_output = ''; 25 26 public function tear_down() { 27 $this->action_output = ''; 28 parent::tear_down(); 29 } 30 14 31 public function test_add_filter_with_function() { 15 32 $callback = '__return_null'; … … 203 220 204 221 public function test_remove_and_add_action() { 205 $this->hook = new WP_Hook(); 206 $this->action_output = ''; 222 $this->hook = new WP_Hook(); 207 223 208 224 $this->hook->add_filter( 'remove_and_add_action', '__return_empty_string', 10, 0 ); … … 218 234 219 235 public function test_remove_and_add_last_action() { 220 $this->hook = new WP_Hook(); 221 $this->action_output = ''; 236 $this->hook = new WP_Hook(); 222 237 223 238 $this->hook->add_filter( 'remove_and_add_action', '__return_empty_string', 10, 0 ); … … 233 248 234 249 public function test_remove_and_recurse_and_add_action() { 235 $this->hook = new WP_Hook(); 236 $this->action_output = ''; 250 $this->hook = new WP_Hook(); 237 251 238 252 $this->hook->add_filter( 'remove_and_add_action', '__return_empty_string', 10, 0 ); -
trunk/tests/phpunit/tests/post/query.php
r52389 r53942 6 6 */ 7 7 class Tests_Post_Query extends WP_UnitTestCase { 8 9 /** 10 * Temporary storage for a post ID for tests using filter callbacks. 11 * 12 * Used in the `test_posts_pre_query_filter_should_respect_set_found_posts()` method. 13 * 14 * @var int 15 */ 16 private $post_id; 17 18 /** 19 * Clean up after each test. 20 */ 21 public function tear_down() { 22 unset( $this->post_id ); 23 24 parent::tear_down(); 25 } 26 8 27 /** 9 28 * @group taxonomy … … 730 749 */ 731 750 public function test_found_posts_should_be_integer_not_string() { 732 $ this->post_id = self::factory()->post->create();751 $post_id = self::factory()->post->create(); 733 752 734 753 $q = new WP_Query( … … 745 764 */ 746 765 public function test_found_posts_should_be_integer_even_if_found_posts_filter_returns_string_value() { 747 $ this->post_id = self::factory()->post->create();766 $post_id = self::factory()->post->create(); 748 767 749 768 add_filter( 'found_posts', '__return_empty_string' ); -
trunk/tests/phpunit/tests/rewrite.php
r52389 r53942 9 9 private $home_url; 10 10 11 /** 12 * Temporary storage for blog id for use with filters. 13 * 14 * Used in the `test_url_to_postid_of_http_site_when_current_site_uses_https()` method. 15 * 16 * @var int 17 */ 18 private $blog_id_35531; 19 11 20 public function set_up() { 12 21 parent::set_up(); … … 23 32 24 33 update_option( 'home', $this->home_url ); 34 unset( $this->blog_id_35531 ); 25 35 parent::tear_down(); 26 36 } -
trunk/tests/phpunit/tests/term/query.php
r51462 r53942 5 5 */ 6 6 class Tests_Term_Query extends WP_UnitTestCase { 7 8 /** 9 * Temporary storage for a term ID for tests using filter callbacks. 10 * 11 * Used in the following tests: 12 * - `test_null_term_object_should_be_discarded()` 13 * - `test_error_term_object_should_be_discarded()` 14 * 15 * @var int 16 */ 17 private $term_id; 18 19 /** 20 * Clean up after each test. 21 */ 22 public function tear_down() { 23 unset( $this->term_id ); 24 25 parent::tear_down(); 26 } 27 7 28 /** 8 29 * @ticket 37545 -
trunk/tests/phpunit/tests/term/wpGetObjectTerms.php
r52921 r53942 8 8 private $taxonomy = 'wptests_tax'; 9 9 10 /** 11 * Temporary storage for taxonomies for tests using filter callbacks. 12 * 13 * Used in the `test_taxonomies_passed_to_wp_get_object_terms_filter_should_be_quoted()` method. 14 * 15 * @var array 16 */ 17 private $taxonomies; 18 10 19 public function set_up() { 11 20 parent::set_up(); 12 21 register_taxonomy( 'wptests_tax', 'post' ); 22 } 23 24 /** 25 * Clean up after each test. 26 */ 27 public function tear_down() { 28 unset( $this->taxonomies ); 29 30 parent::tear_down(); 13 31 } 14 32 -
trunk/tests/phpunit/tests/user/capabilities.php
r53408 r53942 31 31 protected static $block_id; 32 32 33 /** 34 * Temporary storage for roles for tests using filter callbacks. 35 * 36 * Used in the `test_wp_roles_init_action()` method. 37 * 38 * @var array 39 */ 40 private $role_test_wp_roles_init; 41 33 42 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 34 43 self::$users = array( … … 59 68 $this->flush_roles(); 60 69 70 } 71 72 /** 73 * Clean up after each test. 74 */ 75 public function tear_down() { 76 unset( $this->role_test_wp_roles_init ); 77 78 parent::tear_down(); 61 79 } 62 80 … … 1997 2015 } 1998 2016 1999 2000 protected $_role_test_wp_roles_role;2001 2017 /** 2002 2018 * @ticket 23016 2003 2019 */ 2004 2020 public function test_wp_roles_init_action() { 2005 $this-> _role_test_wp_roles_init = array(2021 $this->role_test_wp_roles_init = array( 2006 2022 'role' => 'test_wp_roles_init', 2007 2023 'info' => array( … … 2016 2032 remove_action( 'wp_roles_init', array( $this, '_hook_wp_roles_init' ) ); 2017 2033 2018 $expected = new WP_Role( $this-> _role_test_wp_roles_init['role'], $this->_role_test_wp_roles_init['info']['capabilities'] );2019 2020 $role = $wp_roles->get_role( $this-> _role_test_wp_roles_init['role'] );2034 $expected = new WP_Role( $this->role_test_wp_roles_init['role'], $this->role_test_wp_roles_init['info']['capabilities'] ); 2035 2036 $role = $wp_roles->get_role( $this->role_test_wp_roles_init['role'] ); 2021 2037 2022 2038 $this->assertEquals( $expected, $role ); 2023 $this->assertContains( $this-> _role_test_wp_roles_init['info']['name'], $wp_roles->role_names );2039 $this->assertContains( $this->role_test_wp_roles_init['info']['name'], $wp_roles->role_names ); 2024 2040 } 2025 2041 2026 2042 public function _hook_wp_roles_init( $wp_roles ) { 2027 $wp_roles->add_role( $this-> _role_test_wp_roles_init['role'], $this->_role_test_wp_roles_init['info']['name'], $this->_role_test_wp_roles_init['info']['capabilities'] );2043 $wp_roles->add_role( $this->role_test_wp_roles_init['role'], $this->role_test_wp_roles_init['info']['name'], $this->role_test_wp_roles_init['info']['capabilities'] ); 2028 2044 } 2029 2045
Note: See TracChangeset
for help on using the changeset viewer.