wordpress-develop/tests/phpunit/tests/hooks/iterator.php
Sergey Biryukov 0ec5fb339b Tests: Update the terminology used for action or filter names in hook tests.
This replaces the `$tag` variables with `$hook_name`, to match the core function signatures.

Follow-up to [24/tests], [62/tests], [866/tests], [1294/tests], [38571], [50807].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53804 602fd350-edb4-49c9-b593-d223f7449a82
2022-07-31 15:03:46 +00:00

34 lines
924 B
PHP

<?php
/**
* Test the Iterator implementation of WP_Hook
*
* @group hooks
* @covers WP_Hook::add_filter
*/
class Tests_Hooks_Iterator extends WP_UnitTestCase {
public function test_foreach() {
$callback_one = '__return_null';
$callback_two = '__return_false';
$hook = new WP_Hook();
$hook_name = __FUNCTION__;
$priority = 1;
$accepted_args = 2;
$hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
$hook->add_filter( $hook_name, $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->assertSameSets( array( $priority, $priority + 1 ), $priorities );
$this->assertSameSets( array( $callback_one, $callback_two ), $functions );
}
}