<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[53804] trunk/tests/phpunit/tests: Tests: Update the terminology used for action or filter names in hook tests.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/53804">53804</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/53804","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-07-31 15:03:46 +0000 (Sun, 31 Jul 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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], <a href="https://core.trac.wordpress.org/changeset/38571">[38571]</a>, <a href="https://core.trac.wordpress.org/changeset/50807">[50807]</a>.
See <a href="https://core.trac.wordpress.org/ticket/55652">#55652</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsactionscallbacksphp">trunk/tests/phpunit/tests/actions/callbacks.php</a></li>
<li><a href="#trunktestsphpunittestsactionsclosuresphp">trunk/tests/phpunit/tests/actions/closures.php</a></li>
<li><a href="#trunktestsphpunittestsactionsphp">trunk/tests/phpunit/tests/actions.php</a></li>
<li><a href="#trunktestsphpunittestsfiltersphp">trunk/tests/phpunit/tests/filters.php</a></li>
<li><a href="#trunktestsphpunittestshooksaddFilterphp">trunk/tests/phpunit/tests/hooks/addFilter.php</a></li>
<li><a href="#trunktestsphpunittestshooksapplyFiltersphp">trunk/tests/phpunit/tests/hooks/applyFilters.php</a></li>
<li><a href="#trunktestsphpunittestshooksdoActionphp">trunk/tests/phpunit/tests/hooks/doAction.php</a></li>
<li><a href="#trunktestsphpunittestshooksdoAllHookphp">trunk/tests/phpunit/tests/hooks/doAllHook.php</a></li>
<li><a href="#trunktestsphpunittestshookshasFilterphp">trunk/tests/phpunit/tests/hooks/hasFilter.php</a></li>
<li><a href="#trunktestsphpunittestshookshasFiltersphp">trunk/tests/phpunit/tests/hooks/hasFilters.php</a></li>
<li><a href="#trunktestsphpunittestshooksiteratorphp">trunk/tests/phpunit/tests/hooks/iterator.php</a></li>
<li><a href="#trunktestsphpunittestshookspreinitHooksphp">trunk/tests/phpunit/tests/hooks/preinitHooks.php</a></li>
<li><a href="#trunktestsphpunittestshooksremoveAllFiltersphp">trunk/tests/phpunit/tests/hooks/removeAllFilters.php</a></li>
<li><a href="#trunktestsphpunittestshooksremoveFilterphp">trunk/tests/phpunit/tests/hooks/removeFilter.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsactionscallbacksphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/actions/callbacks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/actions/callbacks.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/actions/callbacks.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,14 +11,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::add_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_callback_representations() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( has_action( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( has_action( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( 'Class', 'method' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( 'Class', 'method' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 10, has_action( $tag, array( 'Class', 'method' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 10, has_action( $hook_name, array( 'Class', 'method' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 10, has_action( $tag, 'Class::method' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 10, has_action( $hook_name, 'Class::method' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsactionsclosuresphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/actions/closures.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/actions/closures.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/actions/closures.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,32 +15,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_closure() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = 'test_action_closure';
- $closure = static function( $a, $b ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = 'test_action_closure';
+ $closure = static function( $a, $b ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS[ $a ] = $b;
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, $closure, 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, $closure, 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 10, has_action( $tag, $closure ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 10, has_action( $hook_name, $closure ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $context = array( 'val1', 'val2' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, $context[0], $context[1] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, $context[0], $context[1] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $GLOBALS[ $context[0] ], $context[1] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag2 = 'test_action_closure_2';
- $closure2 = static function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name2 = 'test_action_closure_2';
+ $closure2 = static function() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['closure_no_args'] = true;
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag2, $closure2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name2, $closure2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 10, has_action( $tag2, $closure2 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 10, has_action( $hook_name2, $closure2 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $GLOBALS['closure_no_args'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_action( $tag, $closure );
- remove_action( $tag2, $closure2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_action( $hook_name, $closure );
+ remove_action( $hook_name2, $closure2 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/actions.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/actions.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,16 +11,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_simple_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a, 'action' ) );
- do_action( $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a, 'action' ) );
+ do_action( $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Only one event occurred for the hook, with empty args.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><span class="cx" style="display: block; padding: 0 10px"> // Only our hook was called.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $argsvar = $a->get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array_pop( $argsvar );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,21 +31,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::remove_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a, 'action' ) );
- do_action( $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a, 'action' ) );
+ do_action( $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure our hook was called correctly.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now remove the action, do it again, and make sure it's not called this time.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_action( $tag, array( &$a, 'action' ) );
- do_action( $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_action( $hook_name, array( &$a, 'action' ) );
+ do_action( $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,17 +53,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::has_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
- $func = __FUNCTION__ . '_func';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
+ $callback = __FUNCTION__ . '_func';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( has_action( $tag, $func ) );
- $this->assertFalse( has_action( $tag ) );
- add_action( $tag, $func );
- $this->assertSame( 10, has_action( $tag, $func ) );
- $this->assertTrue( has_action( $tag ) );
- remove_action( $tag, $func );
- $this->assertFalse( has_action( $tag, $func ) );
- $this->assertFalse( has_action( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( has_action( $hook_name, $callback ) );
+ $this->assertFalse( has_action( $hook_name ) );
+
+ add_action( $hook_name, $callback );
+ $this->assertSame( 10, has_action( $hook_name, $callback ) );
+ $this->assertTrue( has_action( $hook_name ) );
+
+ remove_action( $hook_name, $callback );
+ $this->assertFalse( has_action( $hook_name, $callback ) );
+ $this->assertFalse( has_action( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -72,15 +74,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_multiple_actions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a1 = new MockAction();
- $a2 = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a1 = new MockAction();
+ $a2 = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add both actions to the hook.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a1, 'action' ) );
- add_action( $tag, array( &$a2, 'action' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a1, 'action' ) );
+ add_action( $hook_name, array( &$a2, 'action' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Both actions called once each.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a1->get_call_count() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -93,13 +95,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_args_1() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
- $val = __FUNCTION__ . '_val';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = __FUNCTION__ . '_val';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a, 'action' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a, 'action' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Call the action with a single argument.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, $val );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, $val );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $call_count = $a->get_call_count();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $call_count );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -113,17 +115,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_args_2() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a1 = new MockAction();
- $a2 = new MockAction();
- $tag = __FUNCTION__;
- $val1 = __FUNCTION__ . '_val1';
- $val2 = __FUNCTION__ . '_val2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a1 = new MockAction();
+ $a2 = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val1 = __FUNCTION__ . '_val1';
+ $val2 = __FUNCTION__ . '_val2';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // $a1 accepts two arguments, $a2 doesn't.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a1, 'action' ), 10, 2 );
- add_action( $tag, array( &$a2, 'action' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a1, 'action' ), 10, 2 );
+ add_action( $hook_name, array( &$a2, 'action' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Call the action with two arguments.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, $val1, $val2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, $val1, $val2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $call_count = $a1->get_call_count();
</span><span class="cx" style="display: block; padding: 0 10px"> // $a1 should be called with both args.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,19 +149,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_args_3() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a1 = new MockAction();
- $a2 = new MockAction();
- $a3 = new MockAction();
- $tag = __FUNCTION__;
- $val1 = __FUNCTION__ . '_val1';
- $val2 = __FUNCTION__ . '_val2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a1 = new MockAction();
+ $a2 = new MockAction();
+ $a3 = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val1 = __FUNCTION__ . '_val1';
+ $val2 = __FUNCTION__ . '_val2';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // $a1 accepts two arguments, $a2 doesn't, $a3 accepts two arguments.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a1, 'action' ), 10, 2 );
- add_action( $tag, array( &$a2, 'action' ) );
- add_action( $tag, array( &$a3, 'action' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a1, 'action' ), 10, 2 );
+ add_action( $hook_name, array( &$a2, 'action' ) );
+ add_action( $hook_name, array( &$a3, 'action' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Call the action with two arguments.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, $val1, $val2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, $val1, $val2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $call_count = $a1->get_call_count();
</span><span class="cx" style="display: block; padding: 0 10px"> // $a1 should be called with both args.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -186,13 +188,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_args_with_php4_syntax() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
- $val = new stdClass();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = new stdClass();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a, 'action' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a, 'action' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Call the action with PHP 4 notation for passing object by reference.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, array( &$val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, array( &$val ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $call_count = $a->get_call_count();
</span><span class="cx" style="display: block; padding: 0 10px"> $argsvar = $a->get_args();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,12 +202,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_priority() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a, 'action' ), 10 );
- add_action( $tag, array( &$a, 'action2' ), 9 );
- do_action( $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a, 'action' ), 10 );
+ add_action( $hook_name, array( &$a, 'action2' ), 9 );
+ do_action( $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Two events, one per action.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 2, $a->get_call_count() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -214,13 +216,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // 'action2' is called first because it has priority 9.
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'action' => 'action2',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'tag' => $tag,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'tag' => $hook_name,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'args' => array( '' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> // 'action' is called second.
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'action' => 'action',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'tag' => $tag,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'tag' => $hook_name,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'args' => array( '' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -232,23 +234,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::did_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_did_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag1 = 'action1';
- $tag2 = 'action2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name1 = 'action1';
+ $hook_name2 = 'action2';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Do action $tag1 but not $tag2.
- do_action( $tag1 );
- $this->assertSame( 1, did_action( $tag1 ) );
- $this->assertSame( 0, did_action( $tag2 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Do action $hook_name1 but not $hook_name2.
+ do_action( $hook_name1 );
+ $this->assertSame( 1, did_action( $hook_name1 ) );
+ $this->assertSame( 0, did_action( $hook_name2 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Do action $tag2 10 times.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Do action $hook_name2 10 times.
</ins><span class="cx" style="display: block; padding: 0 10px"> $count = 10;
</span><span class="cx" style="display: block; padding: 0 10px"> for ( $i = 0; $i < $count; $i++ ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name2 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // $tag1's count hasn't changed, $tag2 should be correct.
- $this->assertSame( 1, did_action( $tag1 ) );
- $this->assertSame( $count, did_action( $tag2 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // $hook_name1's count hasn't changed, $hook_name2 should be correct.
+ $this->assertSame( 1, did_action( $hook_name1 ) );
+ $this->assertSame( $count, did_action( $hook_name2 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -256,23 +258,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_all_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag1 = __FUNCTION__ . '_1';
- $tag2 = __FUNCTION__ . '_2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name1 = __FUNCTION__ . '_1';
+ $hook_name2 = __FUNCTION__ . '_2';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add an 'all' action.
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'all', array( &$a, 'action' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 10, has_filter( 'all', array( &$a, 'action' ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> // Do some actions.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag1 );
- do_action( $tag2 );
- do_action( $tag1 );
- do_action( $tag1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name1 );
+ do_action( $hook_name2 );
+ do_action( $hook_name1 );
+ do_action( $hook_name1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Our action should have been called once for each tag.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 4, $a->get_call_count() );
</span><span class="cx" style="display: block; padding: 0 10px"> // Only our hook was called.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag1, $tag2, $tag1, $tag1 ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name1, $hook_name2, $hook_name1, $hook_name1 ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> remove_action( 'all', array( &$a, 'action' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( has_filter( 'all', array( &$a, 'action' ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -283,23 +285,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::remove_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_all_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'all', array( &$a, 'action' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 10, has_filter( 'all', array( &$a, 'action' ) ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure our hook was called correctly.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now remove the action, do it again, and make sure it's not called this time.
</span><span class="cx" style="display: block; padding: 0 10px"> remove_action( 'all', array( &$a, 'action' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( has_filter( 'all', array( &$a, 'action' ) ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -306,13 +308,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action_ref_array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_ref_array() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $obj = new stdClass();
- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $obj = new stdClass();
+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a, 'action' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a, 'action' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action_ref_array( $tag, array( &$obj ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action_ref_array( $hook_name, array( &$obj ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args = $a->get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $args[0][0], $obj );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -329,12 +331,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_keyed_array() {
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( &$a, 'action' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( &$a, 'action' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $context = array( 'key1' => 'val1' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, $context );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, $context );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args = $a->get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $args[0][0], $context );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -343,7 +345,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'key2' => 'val2',
</span><span class="cx" style="display: block; padding: 0 10px"> 'key3' => 'val3',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, $context2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, $context2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args = $a->get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $args[1][0], $context2 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -369,14 +371,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_recursion() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
- $a = new MockAction();
- $b = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
+ $a = new MockAction();
+ $b = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( $a, 'action' ), 11, 1 );
- add_action( $tag, array( $b, 'action' ), 13, 1 );
- add_action( $tag, array( $this, 'action_that_causes_recursion' ), 12, 1 );
- do_action( $tag, $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( $a, 'action' ), 11, 1 );
+ add_action( $hook_name, array( $b, 'action' ), 13, 1 );
+ add_action( $hook_name, array( $this, 'action_that_causes_recursion' ), 12, 1 );
+ do_action( $hook_name, $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 2, $a->get_call_count(), 'recursive actions should call all callbacks with earlier priority' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 2, $b->get_call_count(), 'recursive actions should call callbacks with later priority' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -385,11 +387,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::do_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function action_that_causes_recursion( $tag ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function action_that_causes_recursion( $hook_name ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> static $recursing = false;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $recursing ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $recursing = true;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, $tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, $hook_name );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $recursing = false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -402,19 +404,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::add_action
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_action_callback_manipulation_while_running() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
- $a = new MockAction();
- $b = new MockAction();
- $c = new MockAction();
- $d = new MockAction();
- $e = new MockAction();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
+ $a = new MockAction();
+ $b = new MockAction();
+ $c = new MockAction();
+ $d = new MockAction();
+ $e = new MockAction();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( $a, 'action' ), 11, 2 );
- add_action( $tag, array( $this, 'action_that_manipulates_a_running_hook' ), 12, 2 );
- add_action( $tag, array( $b, 'action' ), 12, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( $a, 'action' ), 11, 2 );
+ add_action( $hook_name, array( $this, 'action_that_manipulates_a_running_hook' ), 12, 2 );
+ add_action( $hook_name, array( $b, 'action' ), 12, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( $tag, $tag, array( $a, $b, $c, $d, $e ) );
- do_action( $tag, $tag, array( $a, $b, $c, $d, $e ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( $hook_name, $hook_name, array( $a, $b, $c, $d, $e ) );
+ do_action( $hook_name, $hook_name, array( $a, $b, $c, $d, $e ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 2, $a->get_call_count(), 'callbacks should run unless otherwise instructed' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $b->get_call_count(), 'callback removed by same priority callback should still get called' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -423,11 +425,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $e->get_call_count(), 'callback added by later priority callback should not get called' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function action_that_manipulates_a_running_hook( $tag, $mocks ) {
- remove_action( $tag, array( $mocks[1], 'action' ), 12, 2 );
- add_action( $tag, array( $mocks[2], 'action' ), 12, 2 );
- add_action( $tag, array( $mocks[3], 'action' ), 13, 2 );
- add_action( $tag, array( $mocks[4], 'action' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function action_that_manipulates_a_running_hook( $hook_name, $mocks ) {
+ remove_action( $hook_name, array( $mocks[1], 'action' ), 12, 2 );
+ add_action( $hook_name, array( $mocks[2], 'action' ), 12, 2 );
+ add_action( $hook_name, array( $mocks[3], 'action' ), 13, 2 );
+ add_action( $hook_name, array( $mocks[4], 'action' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -439,12 +441,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::remove_filter
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_anonymous_callback() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
- $a = new MockAction();
- add_action( $tag, array( $a, 'action' ), 12, 1 );
- $this->assertTrue( has_action( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
+ $a = new MockAction();
+ add_action( $hook_name, array( $a, 'action' ), 12, 1 );
+ $this->assertTrue( has_action( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook = $GLOBALS['wp_filter'][ $tag ];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook = $GLOBALS['wp_filter'][ $hook_name ];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // From http://wordpress.stackexchange.com/a/57088/6445
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $hook as $priority => $filter ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -454,7 +456,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> && 'action' === $function['function'][1]
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name,
</ins><span class="cx" style="display: block; padding: 0 10px"> array( $function['function'][0], 'action' ),
</span><span class="cx" style="display: block; padding: 0 10px"> $priority
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -462,7 +464,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( has_action( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( has_action( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -477,23 +479,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_array_access_of_wp_filter_global() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_filter;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, '__return_null', 11, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertArrayHasKey( 11, $wp_filter[ $tag ] );
- $this->assertArrayHasKey( '__return_null', $wp_filter[ $tag ][11] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, '__return_null', 11, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $wp_filter[ $tag ][11] );
- $this->assertFalse( has_action( $tag, '__return_null' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertArrayHasKey( 11, $wp_filter[ $hook_name ] );
+ $this->assertArrayHasKey( '__return_null', $wp_filter[ $hook_name ][11] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $wp_filter[ $tag ][11] = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ unset( $wp_filter[ $hook_name ][11] );
+ $this->assertFalse( has_action( $hook_name, '__return_null' ) );
+
+ $wp_filter[ $hook_name ][11] = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> '__return_null' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'function' => '__return_null',
</span><span class="cx" style="display: block; padding: 0 10px"> 'accepted_args' => 1,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 11, has_action( $tag, '__return_null' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( 11, has_action( $hook_name, '__return_null' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -505,6 +508,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_current_action() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_current_filter;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_current_filter[] = 'first';
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_current_filter[] = 'second'; // Let's say a second action was invoked.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -518,6 +522,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_doing_filter() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_current_filter;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_current_filter = array(); // Set to an empty array first.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( doing_filter() ); // No filter is passed in, and no filter is being processed.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -539,6 +544,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_doing_action() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_current_filter;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_current_filter = array(); // Set to an empty array first.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( doing_action() ); // No action is passed in, and no filter is being processed.
</span></span></pre></div>
<a id="trunktestsphpunittestsfiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/filters.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/filters.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,17 +8,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Filters extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_simple_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
- $val = __FUNCTION__ . '_val';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = __FUNCTION__ . '_val';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a, 'filter' ) );
- $this->assertSame( $val, apply_filters( $tag, $val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a, 'filter' ) );
+ $this->assertSame( $val, apply_filters( $hook_name, $val ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Only one event occurred for the hook, with empty args.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><span class="cx" style="display: block; padding: 0 10px"> // Only our hook was called.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $argsvar = $a->get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array_pop( $argsvar );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,53 +26,53 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
- $val = __FUNCTION__ . '_val';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = __FUNCTION__ . '_val';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a, 'filter' ) );
- $this->assertSame( $val, apply_filters( $tag, $val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a, 'filter' ) );
+ $this->assertSame( $val, apply_filters( $hook_name, $val ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure our hook was called correctly.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now remove the filter, do it again, and make sure it's not called this time.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( $tag, array( $a, 'filter' ) );
- $this->assertSame( $val, apply_filters( $tag, $val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( $hook_name, array( $a, 'filter' ) );
+ $this->assertSame( $val, apply_filters( $hook_name, $val ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
- $func = __FUNCTION__ . '_func';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
+ $callback = __FUNCTION__ . '_func';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( has_filter( $tag, $func ) );
- $this->assertFalse( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( has_filter( $hook_name, $callback ) );
+ $this->assertFalse( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, $func );
- $this->assertSame( 10, has_filter( $tag, $func ) );
- $this->assertTrue( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, $callback );
+ $this->assertSame( 10, has_filter( $hook_name, $callback ) );
+ $this->assertTrue( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( $tag, $func );
- $this->assertFalse( has_filter( $tag, $func ) );
- $this->assertFalse( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( $hook_name, $callback );
+ $this->assertFalse( has_filter( $hook_name, $callback ) );
+ $this->assertFalse( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // One tag with multiple filters.
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_multiple_filters() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a1 = new MockAction();
- $a2 = new MockAction();
- $tag = __FUNCTION__;
- $val = __FUNCTION__ . '_val';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a1 = new MockAction();
+ $a2 = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = __FUNCTION__ . '_val';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add both filters to the hook.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a1, 'filter' ) );
- add_filter( $tag, array( $a2, 'filter' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a1, 'filter' ) );
+ add_filter( $hook_name, array( $a2, 'filter' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $val, apply_filters( $tag, $val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $val, apply_filters( $hook_name, $val ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Both filters called once each.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a1->get_call_count() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,14 +80,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_filter_args_1() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
- $val = __FUNCTION__ . '_val';
- $arg1 = __FUNCTION__ . '_arg1';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = __FUNCTION__ . '_val';
+ $arg1 = __FUNCTION__ . '_arg1';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a, 'filter' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a, 'filter' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Call the filter with a single argument.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $val, apply_filters( $tag, $val, $arg1 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $val, apply_filters( $hook_name, $val, $arg1 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><span class="cx" style="display: block; padding: 0 10px"> $argsvar = $a->get_args();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -95,18 +95,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_filter_args_2() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a1 = new MockAction();
- $a2 = new MockAction();
- $tag = __FUNCTION__;
- $val = __FUNCTION__ . '_val';
- $arg1 = __FUNCTION__ . '_arg1';
- $arg2 = __FUNCTION__ . '_arg2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a1 = new MockAction();
+ $a2 = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = __FUNCTION__ . '_val';
+ $arg1 = __FUNCTION__ . '_arg1';
+ $arg2 = __FUNCTION__ . '_arg2';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // $a1 accepts two arguments, $a2 doesn't.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a1, 'filter' ), 10, 3 );
- add_filter( $tag, array( $a2, 'filter' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a1, 'filter' ), 10, 3 );
+ add_filter( $hook_name, array( $a2, 'filter' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Call the filter with two arguments.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $val, apply_filters( $tag, $val, $arg1, $arg2 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $val, apply_filters( $hook_name, $val, $arg1, $arg2 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // $a1 should be called with both args.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a1->get_call_count() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -120,14 +120,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_filter_priority() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
- $val = __FUNCTION__ . '_val';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = __FUNCTION__ . '_val';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make two filters with different priorities.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a, 'filter' ), 10 );
- add_filter( $tag, array( $a, 'filter2' ), 9 );
- $this->assertSame( $val, apply_filters( $tag, $val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a, 'filter' ), 10 );
+ add_filter( $hook_name, array( $a, 'filter2' ), 9 );
+ $this->assertSame( $val, apply_filters( $hook_name, $val ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // There should be two events, one per filter.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 2, $a->get_call_count() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,13 +136,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // 'filter2' is called first because it has priority 9.
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'filter' => 'filter2',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'tag' => $tag,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'tag' => $hook_name,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'args' => array( $val ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> // 'filter' is called second.
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'filter' => 'filter',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'tag' => $tag,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'tag' => $hook_name,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'args' => array( $val ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,45 +154,45 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::did_filter
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_did_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag1 = 'filter1';
- $tag2 = 'filter2';
- $val = __FUNCTION__ . '_val';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name1 = 'filter1';
+ $hook_name2 = 'filter2';
+ $val = __FUNCTION__ . '_val';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Apply filter $tag1 but not $tag2.
- apply_filters( $tag1, $val );
- $this->assertSame( 1, did_filter( $tag1 ) );
- $this->assertSame( 0, did_filter( $tag2 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Apply filter $hook_name1 but not $hook_name2.
+ apply_filters( $hook_name1, $val );
+ $this->assertSame( 1, did_filter( $hook_name1 ) );
+ $this->assertSame( 0, did_filter( $hook_name2 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Apply filter $tag2 10 times.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Apply filter $hook_name2 10 times.
</ins><span class="cx" style="display: block; padding: 0 10px"> $count = 10;
</span><span class="cx" style="display: block; padding: 0 10px"> for ( $i = 0; $i < $count; $i++ ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- apply_filters( $tag2, $val );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ apply_filters( $hook_name2, $val );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // $tag1's count hasn't changed, $tag2 should be correct.
- $this->assertSame( 1, did_filter( $tag1 ) );
- $this->assertSame( $count, did_filter( $tag2 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // $hook_name1's count hasn't changed, $hook_name2 should be correct.
+ $this->assertSame( 1, did_filter( $hook_name1 ) );
+ $this->assertSame( $count, did_filter( $hook_name2 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_all_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag1 = __FUNCTION__ . '_1';
- $tag2 = __FUNCTION__ . '_2';
- $val = __FUNCTION__ . '_val';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name1 = __FUNCTION__ . '_1';
+ $hook_name2 = __FUNCTION__ . '_2';
+ $val = __FUNCTION__ . '_val';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add an 'all' filter.
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'all', array( $a, 'filterall' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> // Apply some filters.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $val, apply_filters( $tag1, $val ) );
- $this->assertSame( $val, apply_filters( $tag2, $val ) );
- $this->assertSame( $val, apply_filters( $tag1, $val ) );
- $this->assertSame( $val, apply_filters( $tag1, $val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $val, apply_filters( $hook_name1, $val ) );
+ $this->assertSame( $val, apply_filters( $hook_name2, $val ) );
+ $this->assertSame( $val, apply_filters( $hook_name1, $val ) );
+ $this->assertSame( $val, apply_filters( $hook_name1, $val ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Our filter should have been called once for each apply_filters call.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 4, $a->get_call_count() );
</span><span class="cx" style="display: block; padding: 0 10px"> // The right hooks should have been called in order.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag1, $tag2, $tag1, $tag1 ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name1, $hook_name2, $hook_name1, $hook_name1 ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'all', array( $a, 'filterall' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( has_filter( 'all', array( $a, 'filterall' ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,27 +200,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_all_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
- $val = __FUNCTION__ . '_val';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = __FUNCTION__ . '_val';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'all', array( $a, 'filterall' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( has_filter( 'all' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 10, has_filter( 'all', array( $a, 'filterall' ) ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $val, apply_filters( $tag, $val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $val, apply_filters( $hook_name, $val ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure our hook was called correctly.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now remove the filter, do it again, and make sure it's not called this time.
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'all', array( $a, 'filterall' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( has_filter( 'all', array( $a, 'filterall' ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( has_filter( 'all' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $val, apply_filters( $tag, $val ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $val, apply_filters( $hook_name, $val ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Call cound should remain at 1.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( array( $tag ), $a->get_tags() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( array( $hook_name ), $a->get_tags() );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -227,18 +227,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 20920
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_all_filters_should_respect_the_priority_argument() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a, 'filter' ), 12 );
- $this->assertTrue( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a, 'filter' ), 12 );
+ $this->assertTrue( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Should not be removed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_all_filters( $tag, 11 );
- $this->assertTrue( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_all_filters( $hook_name, 11 );
+ $this->assertTrue( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_all_filters( $tag, 12 );
- $this->assertFalse( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_all_filters( $hook_name, 12 );
+ $this->assertFalse( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -245,14 +245,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 53218
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_filter_with_ref_value() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $obj = new stdClass();
- $ref = &$obj;
- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $obj = new stdClass();
+ $ref = &$obj;
+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( $a, 'filter' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( $a, 'filter' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $filtered = apply_filters( $tag, $ref );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $filtered = apply_filters( $hook_name, $ref );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args = $a->get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $args[0][0], $obj );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -267,15 +267,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 53218
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_filter_with_ref_argument() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $obj = new stdClass();
- $ref = &$obj;
- $a = new MockAction();
- $tag = __FUNCTION__;
- $val = 'Hello';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $obj = new stdClass();
+ $ref = &$obj;
+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
+ $val = 'Hello';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( $a, 'filter' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( $a, 'filter' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- apply_filters( $tag, $val, $ref );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ apply_filters( $hook_name, $val, $ref );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args = $a->get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $args[0][1], $obj );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -288,13 +288,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 9886
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_filter_ref_array() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $obj = new stdClass();
- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $obj = new stdClass();
+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( $a, 'filter' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( $a, 'filter' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- apply_filters_ref_array( $tag, array( &$obj ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ apply_filters_ref_array( $hook_name, array( &$obj ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args = $a->get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $args[0][0], $obj );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -307,15 +307,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 12723
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_filter_ref_array_result() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $obj = new stdClass();
- $a = new MockAction();
- $b = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $obj = new stdClass();
+ $a = new MockAction();
+ $b = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( $tag, array( $a, 'filter_append' ), 10, 2 );
- add_action( $tag, array( $b, 'filter_append' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( $hook_name, array( $a, 'filter_append' ), 10, 2 );
+ add_action( $hook_name, array( $b, 'filter_append' ), 10, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = apply_filters_ref_array( $tag, array( 'string', &$obj ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = apply_filters_ref_array( $hook_name, array( 'string', &$obj ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $result, 'string_append_append' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -337,25 +337,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 29070
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_filter_after_remove_all_filters() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No priority.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a, 'filter' ), 11 );
- add_filter( $tag, array( $a, 'filter' ), 12 );
- $this->assertTrue( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a, 'filter' ), 11 );
+ add_filter( $hook_name, array( $a, 'filter' ), 12 );
+ $this->assertTrue( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_all_filters( $tag );
- $this->assertFalse( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_all_filters( $hook_name );
+ $this->assertFalse( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Remove priorities one at a time.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( $tag, array( $a, 'filter' ), 11 );
- add_filter( $tag, array( $a, 'filter' ), 12 );
- $this->assertTrue( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( $hook_name, array( $a, 'filter' ), 11 );
+ add_filter( $hook_name, array( $a, 'filter' ), 12 );
+ $this->assertTrue( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_all_filters( $tag, 11 );
- remove_all_filters( $tag, 12 );
- $this->assertFalse( has_filter( $tag ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_all_filters( $hook_name, 11 );
+ remove_all_filters( $hook_name, 12 );
+ $this->assertFalse( has_filter( $hook_name ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -412,6 +412,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> private $current_priority;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 39007
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -425,6 +426,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function current_priority_action() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_filter;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->current_priority = $wp_filter[ current_filter() ]->current_priority();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunittestshooksaddFilterphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/addFilter.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/addFilter.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/addFilter.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,13 +14,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_filter_with_function() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $function_index = _wp_filter_build_unique_id( $hook_name, $callback, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,13 +29,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $a, 'action' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $function_index = _wp_filter_build_unique_id( $hook_name, $callback, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,13 +43,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_filter_with_static_method() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( 'MockAction', 'action' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $function_index = _wp_filter_build_unique_id( $hook_name, $callback, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -58,14 +58,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_one = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_two = '__return_false';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_two, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_two, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -73,14 +73,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_one = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_two = '__return_false';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_two, $priority + 1, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,14 +88,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_readd_filter() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,34 +102,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_readd_filter_with_different_priority() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority + 1, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority + 1, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_sort_after_add_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $a = new MockAction();
- $b = new MockAction();
- $c = new MockAction();
- $hook = new WP_Hook();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $a = new MockAction();
+ $b = new MockAction();
+ $c = new MockAction();
+ $hook = new WP_Hook();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, array( $a, 'action' ), 10, 1 );
- $hook->add_filter( $tag, array( $b, 'action' ), 5, 1 );
- $hook->add_filter( $tag, array( $c, 'action' ), 8, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, array( $a, 'action' ), 10, 1 );
+ $hook->add_filter( $hook_name, array( $b, 'action' ), 5, 1 );
+ $hook->add_filter( $hook_name, array( $c, 'action' ), 8, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( 5, 8, 10 ), array_keys( $hook->callbacks ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_and_add() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->hook = new Wp_Hook();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->hook = new WP_Hook();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->hook->add_filter( 'remove_and_add', '__return_empty_string', 10, 0 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,7 +143,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_and_add_last_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->hook = new Wp_Hook();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->hook = new WP_Hook();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->hook->add_filter( 'remove_and_add', '__return_empty_string', 10, 0 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -157,7 +157,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_and_recurse_and_add() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->hook = new Wp_Hook();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->hook = new WP_Hook();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->hook->add_filter( 'remove_and_add', '__return_empty_string', 10, 0 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -202,7 +202,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_and_add_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->hook = new Wp_Hook();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->hook = new WP_Hook();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->action_output = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->hook->add_filter( 'remove_and_add_action', '__return_empty_string', 10, 0 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -217,7 +217,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_and_add_last_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->hook = new Wp_Hook();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->hook = new WP_Hook();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->action_output = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->hook->add_filter( 'remove_and_add_action', '__return_empty_string', 10, 0 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -232,7 +232,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_and_recurse_and_add_action() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->hook = new Wp_Hook();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->hook = new WP_Hook();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->action_output = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->hook->add_filter( 'remove_and_add_action', '__return_empty_string', 10, 0 );
</span></span></pre></div>
<a id="trunktestsphpunittestshooksapplyFiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/applyFilters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/applyFilters.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/applyFilters.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,12 +12,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $a, 'filter' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $returned = $hook->apply_filters( $arg, array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,12 +29,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $a, 'filter' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $returned_one = $hook->apply_filters( $arg, array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $returned_two = $hook->apply_filters( $returned_one, array( $returned_one ) );
</span></span></pre></div>
<a id="trunktestsphpunittestshooksdoActionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/doAction.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/doAction.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/doAction.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -20,12 +20,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $a, 'action' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $hook->do_action( array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,12 +35,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $a, 'filter' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $hook->do_action( array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook->do_action( array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,13 +53,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_one = array( $a, 'filter' );
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_two = array( $b, 'filter' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
- $hook->add_filter( $tag, $callback_two, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
+ $hook->add_filter( $hook_name, $callback_two, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $hook->do_action( array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -72,13 +72,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_one = array( $a, 'filter' );
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_two = array( $b, 'filter' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
- $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
+ $hook->add_filter( $hook_name, $callback_two, $priority + 1, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $hook->do_action( array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $a->get_call_count() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,12 +88,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_do_action_with_no_accepted_args() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $this, '_action_callback' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $hook->do_action( array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $this->events[0]['args'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,12 +102,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_do_action_with_one_accepted_arg() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $this, '_action_callback' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $hook->do_action( array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $this->events[0]['args'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -116,12 +116,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_do_action_with_more_accepted_args() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $this, '_action_callback' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 100;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 1000;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = __FUNCTION__ . '_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $hook->do_action( array( $arg ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $this->events[0]['args'] );
</span></span></pre></div>
<a id="trunktestsphpunittestshooksdoAllHookphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/doAllHook.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/doAllHook.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/doAllHook.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,12 +12,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $a, 'action' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = 'all';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = 'all';
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $arg = 'all_arg';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = array( $arg );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook->do_all_hook( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook->do_all_hook( $args );
</span></span></pre></div>
<a id="trunktestsphpunittestshookshasFilterphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/hasFilter.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/hasFilter.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/hasFilter.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,13 +11,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_filter_with_function() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $priority, $hook->has_filter( $hook_name, $callback ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_filter_with_object() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,35 +24,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $a, 'action' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $priority, $hook->has_filter( $hook_name, $callback ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_filter_with_static_method() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( 'MockAction', 'action' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $priority, $hook->has_filter( $hook_name, $callback ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_filter_without_callback() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $hook->has_filter() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,22 +63,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_not_has_filter_with_callback() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $callback = '__return_null';
- $hook = new WP_Hook();
- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $callback = '__return_null';
+ $hook = new WP_Hook();
+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $hook->has_filter( $tag, $callback ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $hook->has_filter( $hook_name, $callback ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_filter_with_wrong_callback() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $hook->has_filter( $tag, '__return_false' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $hook->has_filter( $hook_name, '__return_false' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestshookshasFiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/hasFilters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/hasFilters.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/hasFilters.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,11 +11,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_has_filters_with_callback() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $hook->has_filters() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,12 +28,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_not_has_filters_with_removed_callback() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
- $hook->remove_filter( $tag, $callback, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
+ $hook->remove_filter( $hook_name, $callback, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $hook->has_filters() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,12 +40,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_not_has_filter_with_directly_removed_callback() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
- $function_key = _wp_filter_build_unique_id( $tag, $callback, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
+ $function_key = _wp_filter_build_unique_id( $hook_name, $callback, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px"> unset( $hook->callbacks[ $priority ][ $function_key ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $hook->has_filters() );
</span></span></pre></div>
<a id="trunktestsphpunittestshooksiteratorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/iterator.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/iterator.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/iterator.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,12 +12,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_one = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_two = '__return_false';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
- $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
+ $hook->add_filter( $hook_name, $callback_two, $priority + 1, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $functions = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $priorities = array();
</span></span></pre></div>
<a id="trunktestsphpunittestshookspreinitHooksphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/preinitHooks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/preinitHooks.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/preinitHooks.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9,12 +9,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Hooks_PreinitHooks extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_array_to_hooks() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag1 = __FUNCTION__ . '_1';
- $priority1 = 1;
- $tag2 = __FUNCTION__ . '_2';
- $priority2 = 2;
- $filters = array(
- $tag1 => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name1 = __FUNCTION__ . '_1';
+ $priority1 = 1;
+ $hook_name2 = __FUNCTION__ . '_2';
+ $priority2 = 2;
+ $filters = array(
+ $hook_name1 => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority1 => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'test1' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'function' => '__return_false',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,7 +22,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag2 => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name2 => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority2 => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'test1' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'function' => '__return_null',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -34,7 +34,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $hooks = WP_Hook::build_preinitialized_hooks( $filters );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $priority1, $hooks[ $tag1 ]->has_filter( $tag1, '__return_false' ) );
- $this->assertSame( $priority2, $hooks[ $tag2 ]->has_filter( $tag2, '__return_null' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $priority1, $hooks[ $hook_name1 ]->has_filter( $hook_name1, '__return_false' ) );
+ $this->assertSame( $priority2, $hooks[ $hook_name2 ]->has_filter( $hook_name2, '__return_null' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestshooksremoveAllFiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/removeAllFilters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/removeAllFilters.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/removeAllFilters.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,11 +11,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_all_filters() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $hook->remove_all_filters();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,17 +26,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_one = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_two = '__return_false';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
- $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
+ $hook->add_filter( $hook_name, $callback_two, $priority + 1, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $hook->remove_all_filters( $priority );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $hook->has_filter( $tag, $callback_one ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $hook->has_filter( $hook_name, $callback_one ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $hook->has_filters() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $priority + 1, $hook->has_filter( $tag, $callback_two ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $priority + 1, $hook->has_filter( $hook_name, $callback_two ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestshooksremoveFilterphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/hooks/removeFilter.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/hooks/removeFilter.php 2022-07-31 14:18:36 UTC (rev 53803)
+++ trunk/tests/phpunit/tests/hooks/removeFilter.php 2022-07-31 15:03:46 UTC (rev 53804)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,12 +11,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_filter_with_function() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
- $hook->remove_filter( $tag, $callback, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
+ $hook->remove_filter( $hook_name, $callback, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayNotHasKey( $priority, $hook->callbacks );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -25,12 +25,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = new MockAction();
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( $a, 'action' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
- $hook->remove_filter( $tag, $callback, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
+ $hook->remove_filter( $hook_name, $callback, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayNotHasKey( $priority, $hook->callbacks );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,12 +38,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_remove_filter_with_static_method() {
</span><span class="cx" style="display: block; padding: 0 10px"> $callback = array( 'MockAction', 'action' );
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback, $priority, $accepted_args );
- $hook->remove_filter( $tag, $callback, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
+ $hook->remove_filter( $hook_name, $callback, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayNotHasKey( $priority, $hook->callbacks );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,14 +52,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_one = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_two = '__return_false';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
- $hook->add_filter( $tag, $callback_two, $priority, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
+ $hook->add_filter( $hook_name, $callback_two, $priority, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->remove_filter( $tag, $callback_one, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->remove_filter( $hook_name, $callback_one, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -68,14 +68,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_one = '__return_null';
</span><span class="cx" style="display: block; padding: 0 10px"> $callback_two = '__return_false';
</span><span class="cx" style="display: block; padding: 0 10px"> $hook = new WP_Hook();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag = __FUNCTION__;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook_name = __FUNCTION__;
</ins><span class="cx" style="display: block; padding: 0 10px"> $priority = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> $accepted_args = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
- $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
+ $hook->add_filter( $hook_name, $callback_two, $priority + 1, $accepted_args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $hook->remove_filter( $tag, $callback_one, $priority );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hook->remove_filter( $hook_name, $callback_one, $priority );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayNotHasKey( $priority, $hook->callbacks );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>