mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Although unlikely, clashes in randomly generated strings could cause unexpected failures. In addition, most randomness is entirely unnecessary, is bad practice, and increases test time (however small it may be). See #37371 git-svn-id: https://develop.svn.wordpress.org/trunk@38762 602fd350-edb4-49c9-b593-d223f7449a82
33 lines
884 B
PHP
Executable File
33 lines
884 B
PHP
Executable File
<?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 );
|
|
}
|
|
}
|