mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorg *_action and *_filter functions.
Moves the actions.php and filters.php test files into the `hooks` directory. Adds the `Hooks` `<GroupName>` to each of the test classes for consistency with coding standards. Splits each function into its own test class/file. Reorg *_action and *_filter functions
- Loading branch information
1 parent
b12b432
commit 9ca1394
Showing
19 changed files
with
756 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* Test add_action(). | ||
* | ||
* @group hooks | ||
* @covers ::add_action | ||
*/ | ||
class Tests_Hooks_AddAction extends WP_UnitTestCase { | ||
/** | ||
* @ticket 23265 | ||
*/ | ||
public function test_action_callback_representations() { | ||
$hook_name = __FUNCTION__; | ||
|
||
$this->assertFalse( has_action( $hook_name ) ); | ||
|
||
add_action( $hook_name, array( 'Class', 'method' ) ); | ||
|
||
$this->assertSame( 10, has_action( $hook_name, array( 'Class', 'method' ) ) ); | ||
|
||
$this->assertSame( 10, has_action( $hook_name, 'Class::method' ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* Test apply_filters_deprecated(). | ||
* | ||
* @group hooks | ||
* @covers ::apply_filters_deprecated | ||
*/ | ||
class Tests_Hooks_ApplyFiltersDeprecated extends WP_UnitTestCase { | ||
|
||
/** | ||
* @ticket 10441 | ||
* @expectedDeprecated tests_apply_filters_deprecated | ||
*/ | ||
public function test_apply_filters_deprecated() { | ||
$p = 'Foo'; | ||
|
||
add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) ); | ||
$p = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p ), '4.6.0' ); | ||
remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback' ) ); | ||
|
||
$this->assertSame( 'Bar', $p ); | ||
} | ||
|
||
public static function deprecated_filter_callback( $p ) { | ||
$p = 'Bar'; | ||
return $p; | ||
} | ||
|
||
/** | ||
* @ticket 10441 | ||
* @expectedDeprecated tests_apply_filters_deprecated | ||
*/ | ||
public function test_apply_filters_deprecated_with_multiple_params() { | ||
$p1 = 'Foo1'; | ||
$p2 = 'Foo2'; | ||
|
||
add_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 ); | ||
$p1 = apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $p1, $p2 ), '4.6.0' ); | ||
remove_filter( 'tests_apply_filters_deprecated', array( __CLASS__, 'deprecated_filter_callback_multiple_params' ), 10, 2 ); | ||
|
||
$this->assertSame( 'Bar1', $p1 ); | ||
|
||
// Not passed by reference, so not modified. | ||
$this->assertSame( 'Foo2', $p2 ); | ||
} | ||
|
||
public static function deprecated_filter_callback_multiple_params( $p1, $p2 ) { | ||
$p1 = 'Bar1'; | ||
$p2 = 'Bar2'; | ||
|
||
return $p1; | ||
} | ||
|
||
/** | ||
* @ticket 10441 | ||
*/ | ||
public function test_apply_filters_deprecated_without_filter() { | ||
$val = 'Foobar'; | ||
|
||
$this->assertSame( $val, apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $val ), '4.6.0' ) ); | ||
} | ||
} |
Oops, something went wrong.