forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterator.php
More file actions
32 lines (28 loc) · 911 Bytes
/
iterator.php
File metadata and controls
32 lines (28 loc) · 911 Bytes
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
<?php
/**
* Test the Iterator implementation of WP_Hook
*
* @group hooks
*/
class Tests_WP_Hook_Iterator extends WP_UnitTestCase {
public function test_foreach() {
$callback_one = '__return_null';
$callback_two = '__return_false';
$hook = new WP_Hook();
$tag = __FUNCTION__;
$priority = rand( 1, 100 );
$accepted_args = rand( 1, 100 );
$hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
$hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args );
$functions = array();
$priorities = array();
foreach ( $hook as $key => $callbacks ) {
$priorities[] = $key;
foreach ( $callbacks as $function_index => $the_ ) {
$functions[] = $the_['function'];
}
}
$this->assertEqualSets( array( $priority, $priority + 1 ), $priorities );
$this->assertEqualSets( array( $callback_one, $callback_two ), $functions );
}
}