forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhasFilters.php
More file actions
53 lines (43 loc) · 1.51 KB
/
hasFilters.php
File metadata and controls
53 lines (43 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* Test the has_filters method of WP_Hook
*
* @group hooks
* @covers WP_Hook::has_filters
*/
class Tests_Hooks_HasFilters extends WP_UnitTestCase {
public function test_has_filters_with_callback() {
$callback = '__return_null';
$hook = new WP_Hook();
$tag = __FUNCTION__;
$priority = rand( 1, 100 );
$accepted_args = rand( 1, 100 );
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
$this->assertTrue( $hook->has_filters() );
}
public function test_has_filters_without_callback() {
$hook = new WP_Hook();
$this->assertFalse( $hook->has_filters() );
}
public function test_not_has_filters_with_removed_callback() {
$callback = '__return_null';
$hook = new WP_Hook();
$tag = __FUNCTION__;
$priority = rand( 1, 100 );
$accepted_args = rand( 1, 100 );
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
$hook->remove_filter( $tag, $callback, $priority );
$this->assertFalse( $hook->has_filters() );
}
public function test_not_has_filter_with_directly_removed_callback() {
$callback = '__return_null';
$hook = new WP_Hook();
$tag = __FUNCTION__;
$priority = rand( 1, 100 );
$accepted_args = rand( 1, 100 );
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
$function_key = _wp_filter_build_unique_id( $tag, $callback, $priority );
unset( $hook->callbacks[ $priority ][ $function_key ] );
$this->assertFalse( $hook->has_filters() );
}
}