mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-28 13:00:19 +00:00
This ensures that not only the return values match the expected results, but also that their type is the same. Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable. Props johnbillion, jrf, SergeyBiryukov. See #38266. git-svn-id: https://develop.svn.wordpress.org/trunk@48937 602fd350-edb4-49c9-b593-d223f7449a82
40 lines
918 B
PHP
40 lines
918 B
PHP
<?php
|
|
|
|
/**
|
|
* Test the IteratorAggregate implementation of WP_Hook
|
|
*
|
|
* @group hooks
|
|
*/
|
|
class Tests_WP_Hook_Preinit_Hooks extends WP_UnitTestCase {
|
|
|
|
public function test_array_to_hooks() {
|
|
$tag1 = __FUNCTION__ . '_1';
|
|
$priority1 = rand( 1, 100 );
|
|
$tag2 = __FUNCTION__ . '_2';
|
|
$priority2 = rand( 1, 100 );
|
|
$filters = array(
|
|
$tag1 => array(
|
|
$priority1 => array(
|
|
'test1' => array(
|
|
'function' => '__return_false',
|
|
'accepted_args' => 2,
|
|
),
|
|
),
|
|
),
|
|
$tag2 => array(
|
|
$priority2 => array(
|
|
'test1' => array(
|
|
'function' => '__return_null',
|
|
'accepted_args' => 1,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
$hooks = WP_Hook::build_preinitialized_hooks( $filters );
|
|
|
|
$this->assertSame( $priority1, $hooks[ $tag1 ]->has_filter( $tag1, '__return_false' ) );
|
|
$this->assertSame( $priority2, $hooks[ $tag2 ]->has_filter( $tag2, '__return_null' ) );
|
|
}
|
|
}
|