<!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>[53836] trunk/tests/phpunit/tests: Tests: Combine test classes for `get_edit_term_link()` 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/53836">53836</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/53836","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-08-04 18:28:33 +0000 (Thu, 04 Aug 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: Combine test classes for `get_edit_term_link()` tests.

There were two sets of tests for the function:
* One in the `link` directory, based on the `link-template.php` file name.
* One in the `term` directory, based on the component name.

To avoid confusion and make it easier to decide where new tests should go in the future, the existing tests are now combined in the former location.

Includes:
* Setting the current user in `::set_up()` instead of each individual test method.
* Changing the custom taxonomy name to `wptests_tax` for consistency with other tests.
* Moving `::register_custom_taxonomy()` and `::get_term()` helpers to the beginning of the class.

Follow-up to <a href="https://core.trac.wordpress.org/changeset/32954">[32954]</a>, <a href="https://core.trac.wordpress.org/changeset/36646">[36646]</a>, <a href="https://core.trac.wordpress.org/changeset/52180">[52180]</a>, <a href="https://core.trac.wordpress.org/changeset/52255">[52255]</a>, <a href="https://core.trac.wordpress.org/changeset/53833">[53833]</a>.

See <a href="https://core.trac.wordpress.org/ticket/55652">#55652</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestslinkeditTermLinkphp">trunk/tests/phpunit/tests/link/editTermLink.php</a></li>
<li><a href="#trunktestsphpunittestslinkgetEditTermLinkphp">trunk/tests/phpunit/tests/link/getEditTermLink.php</a></li>
<li><a href="#trunktestsphpunitteststermgetTermLinkphp">trunk/tests/phpunit/tests/term/getTermLink.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunitteststermgetEditTermLinkphp">trunk/tests/phpunit/tests/term/getEditTermLink.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestslinkeditTermLinkphp"></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/link/editTermLink.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/link/editTermLink.php   2022-08-04 17:47:41 UTC (rev 53835)
+++ trunk/tests/phpunit/tests/link/editTermLink.php     2022-08-04 18:28:33 UTC (rev 53836)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,7 +12,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
</span><span class="cx" style="display: block; padding: 0 10px">                self::register_custom_taxonomy();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $taxonomies = array( 'category', 'post_tag', 'custom_taxonomy' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $taxonomies = array( 'category', 'post_tag', 'wptests_tax' );
</ins><span class="cx" style="display: block; padding: 0 10px">                 foreach ( $taxonomies as $taxonomy ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        self::$terms[ $taxonomy ] = $factory->term->create_and_get( array( 'taxonomy' => $taxonomy ) );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,10 +23,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function set_up() {
</span><span class="cx" style="display: block; padding: 0 10px">                parent::set_up();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                wp_set_current_user( self::$user_ids['admin'] );
</ins><span class="cx" style="display: block; padding: 0 10px">                 self::register_custom_taxonomy();
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Helper to register a custom taxonomy for use in tests.
+        *
+        * @since 5.9.0
+        */
+       private static function register_custom_taxonomy() {
+               register_taxonomy( 'wptests_tax', 'post' );
+       }
+
+       /**
+        * Helper to get the term for the given taxonomy.
+        *
+        * @since 5.9.0
+        *
+        * @param string $taxonomy Taxonomy being tested (used for index of term keys).
+        * @param bool   $use_id   When true, pass term ID. Else, pass term object.
+        * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term.
+        */
+       private function get_term( $taxonomy, $use_id ) {
+               $term = self::$terms[ $taxonomy ];
+               if ( $use_id ) {
+                       $term = $term->term_id;
+               }
+
+               return $term;
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * @dataProvider data_edit_term_link
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 50225
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,7 +64,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $expected Expected URL within admin of edit link.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_edit_term_link_for_permitted_user( $taxonomy, $use_id, $expected ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_set_current_user( self::$user_ids['admin'] );
</del><span class="cx" style="display: block; padding: 0 10px">                 $term = $this->get_term( $taxonomy, $use_id );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Term IDs are not known by the data provider so need to be replaced.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -72,7 +99,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param bool   $use_id   When true, pass term ID. Else, pass term object.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_edit_term_link_filter_is_int_by_term_id( $taxonomy, $use_id ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_set_current_user( self::$user_ids['admin'] );
</del><span class="cx" style="display: block; padding: 0 10px">                 $term = $this->get_term( $taxonomy, $use_id );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,7 +122,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param bool   $use_id   When true, pass term ID. Else, pass term object.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_edit_term_link_filter_is_int_by_term_object( $taxonomy, $use_id ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_set_current_user( self::$user_ids['admin'] );
</del><span class="cx" style="display: block; padding: 0 10px">                 $term = $this->get_term( $taxonomy, $use_id );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,42 +164,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'expected' => 'term.php?taxonomy=post_tag&tag_ID=%ID%&post_type=post',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'a custom taxonomy passing term_id'     => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'taxonomy' => 'custom_taxonomy',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'taxonomy' => 'wptests_tax',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'use_id'   => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'expected' => 'term.php?taxonomy=custom_taxonomy&tag_ID=%ID%&post_type=post',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'expected' => 'term.php?taxonomy=wptests_tax&tag_ID=%ID%&post_type=post',
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'a custom taxonomy passing term object' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'taxonomy' => 'custom_taxonomy',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'taxonomy' => 'wptests_tax',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'use_id'   => false,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'expected' => 'term.php?taxonomy=custom_taxonomy&tag_ID=%ID%&post_type=post',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'expected' => 'term.php?taxonomy=wptests_tax&tag_ID=%ID%&post_type=post',
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       /**
-        * Helper to register a custom taxonomy for use in tests.
-        *
-        * @since 5.9.0
-        */
-       private static function register_custom_taxonomy() {
-               register_taxonomy( 'custom_taxonomy', 'post' );
-       }
-
-       /**
-        * Helper to get the term for the given taxonomy.
-        *
-        * @since 5.9.0
-        *
-        * @param string $taxonomy Taxonomy being tested (used for index of term keys).
-        * @param bool   $use_id   When true, pass term ID. Else, pass term object.
-        * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term.
-        */
-       private function get_term( $taxonomy, $use_id ) {
-               $term = self::$terms[ $taxonomy ];
-               if ( $use_id ) {
-                       $term = $term->term_id;
-               }
-
-               return $term;
-       }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestslinkgetEditTermLinkphp"></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/link/getEditTermLink.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/link/getEditTermLink.php        2022-08-04 17:47:41 UTC (rev 53835)
+++ trunk/tests/phpunit/tests/link/getEditTermLink.php  2022-08-04 18:28:33 UTC (rev 53836)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,7 +12,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
</span><span class="cx" style="display: block; padding: 0 10px">                self::register_custom_taxonomy();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $taxonomies = array( 'category', 'post_tag', 'custom_taxonomy' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $taxonomies = array( 'category', 'post_tag', 'wptests_tax' );
</ins><span class="cx" style="display: block; padding: 0 10px">                 foreach ( $taxonomies as $taxonomy ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        self::$terms[ $taxonomy ] = $factory->term->create_and_get( array( 'taxonomy' => $taxonomy ) );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,10 +23,124 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function set_up() {
</span><span class="cx" style="display: block; padding: 0 10px">                parent::set_up();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                wp_set_current_user( self::$user_ids['admin'] );
</ins><span class="cx" style="display: block; padding: 0 10px">                 self::register_custom_taxonomy();
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Helper to register a custom taxonomy for use in tests.
+        *
+        * @since 5.9.0
+        */
+       private static function register_custom_taxonomy() {
+               register_taxonomy( 'wptests_tax', 'post' );
+       }
+
+       /**
+        * Helper to get the term for the given taxonomy.
+        *
+        * @since 5.9.0
+        *
+        * @param string $taxonomy Taxonomy being tested (used for index of term keys).
+        * @param bool   $use_id   When true, pass term ID. Else, pass term object.
+        * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term.
+        */
+       private function get_term( $taxonomy, $use_id ) {
+               $term = self::$terms[ $taxonomy ];
+               if ( $use_id ) {
+                       $term = $term->term_id;
+               }
+
+               return $term;
+       }
+
+       public function test_get_edit_term_link_default() {
+               $term1 = self::factory()->term->create(
+                       array(
+                               'taxonomy' => 'wptests_tax',
+                               'name'     => 'foo',
+                       )
+               );
+
+               $actual   = get_edit_term_link( $term1, 'wptests_tax' );
+               $expected = 'http://' . WP_TESTS_DOMAIN . '/wp-admin/term.php?taxonomy=wptests_tax&tag_ID=' . $term1 . '&post_type=post';
+               $this->assertSame( $expected, $actual );
+       }
+
+       /**
+        * @ticket 32786
+        */
+       public function test_get_edit_term_link_invalid_id() {
+               $term1 = self::factory()->term->create(
+                       array(
+                               'taxonomy' => 'wptests_tax',
+                               'name'     => 'foo',
+                       )
+               );
+
+               $actual = get_edit_term_link( 12345, 'wptests_tax' );
+               $this->assertNull( $actual );
+       }
+
+       /**
+        * @ticket 32786
+        */
+       public function test_get_edit_term_link_empty_id() {
+               $actual = get_edit_term_link( '', 'wptests_tax' );
+               $this->assertNull( $actual );
+       }
+
+       /**
+        * @ticket 32786
+        */
+       public function test_get_edit_term_link_bad_tax() {
+               $actual = get_edit_term_link( '', 'bad_tax' );
+               $this->assertNull( $actual );
+       }
+
+       /**
+        * @ticket 35922
+        */
+       public function test_taxonomy_should_not_be_required() {
+               $t = self::factory()->term->create(
+                       array(
+                               'taxonomy' => 'wptests_tax',
+                               'name'     => 'foo',
+                       )
+               );
+
+               $actual = get_edit_term_link( $t );
+               $this->assertNotNull( $actual );
+       }
+
+       /**
+        * @ticket 35922
+        */
+       public function test_cap_check_should_use_correct_taxonomy_when_taxonomy_is_not_specified() {
+               register_taxonomy(
+                       'wptests_tax_subscriber',
+                       'post',
+                       array(
+                               'capabilities' => array(
+                                       'edit_terms' => 'read',
+                               ),
+                       )
+               );
+
+               $t = self::factory()->term->create(
+                       array(
+                               'taxonomy' => 'wptests_tax_subscriber',
+                               'name'     => 'foo',
+                       )
+               );
+
+               wp_set_current_user( self::$user_ids['subscriber'] );
+
+               $actual = get_edit_term_link( $t );
+               $this->assertNotNull( $actual );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * @dataProvider data_get_edit_term_link
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 50225
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,7 +150,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $expected Expected URL within admin of edit link.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_edit_term_link_for_permitted_user( $taxonomy, $use_id, $expected ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_set_current_user( self::$user_ids['admin'] );
</del><span class="cx" style="display: block; padding: 0 10px">                 $term = $this->get_term( $taxonomy, $use_id );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Term IDs are not known by the data provider so need to be replaced.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -72,7 +185,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param bool   $use_id   When true, pass term ID. Else, pass term object.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_edit_term_link_filter_is_int_by_term_id( $taxonomy, $use_id ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_set_current_user( self::$user_ids['admin'] );
</del><span class="cx" style="display: block; padding: 0 10px">                 $term = $this->get_term( $taxonomy, $use_id );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,7 +208,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param bool   $use_id   When true, pass term ID. Else, pass term object.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_edit_term_link_filter_is_int_by_term_object( $taxonomy, $use_id ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_set_current_user( self::$user_ids['admin'] );
</del><span class="cx" style="display: block; padding: 0 10px">                 $term = $this->get_term( $taxonomy, $use_id );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,42 +250,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'expected' => 'term.php?taxonomy=post_tag&tag_ID=%ID%&post_type=post',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'a custom taxonomy passing term_id'     => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'taxonomy' => 'custom_taxonomy',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'taxonomy' => 'wptests_tax',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'use_id'   => true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'expected' => 'term.php?taxonomy=custom_taxonomy&tag_ID=%ID%&post_type=post',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'expected' => 'term.php?taxonomy=wptests_tax&tag_ID=%ID%&post_type=post',
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'a custom taxonomy passing term object' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'taxonomy' => 'custom_taxonomy',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'taxonomy' => 'wptests_tax',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'use_id'   => false,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'expected' => 'term.php?taxonomy=custom_taxonomy&tag_ID=%ID%&post_type=post',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'expected' => 'term.php?taxonomy=wptests_tax&tag_ID=%ID%&post_type=post',
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       /**
-        * Helper to register a custom taxonomy for use in tests.
-        *
-        * @since 5.9.0
-        */
-       private static function register_custom_taxonomy() {
-               register_taxonomy( 'custom_taxonomy', 'post' );
-       }
-
-       /**
-        * Helper to get the term for the given taxonomy.
-        *
-        * @since 5.9.0
-        *
-        * @param string $taxonomy Taxonomy being tested (used for index of term keys).
-        * @param bool   $use_id   When true, pass term ID. Else, pass term object.
-        * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term.
-        */
-       private function get_term( $taxonomy, $use_id ) {
-               $term = self::$terms[ $taxonomy ];
-               if ( $use_id ) {
-                       $term = $term->term_id;
-               }
-
-               return $term;
-       }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunitteststermgetEditTermLinkphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/term/getEditTermLink.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getEditTermLink.php        2022-08-04 17:47:41 UTC (rev 53835)
+++ trunk/tests/phpunit/tests/term/getEditTermLink.php  2022-08-04 18:28:33 UTC (rev 53836)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,103 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-/**
- * @group taxonomy
- */
-class Tests_Term_GetEditTermLink extends WP_UnitTestCase {
-       public function set_up() {
-               parent::set_up();
-               wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
-               register_taxonomy( 'wptests_tax', 'post' );
-       }
-
-       public function test_get_edit_term_link_default() {
-               $term1 = self::factory()->term->create(
-                       array(
-                               'taxonomy' => 'wptests_tax',
-                               'name'     => 'foo',
-                       )
-               );
-
-               $actual   = get_edit_term_link( $term1, 'wptests_tax' );
-               $expected = 'http://' . WP_TESTS_DOMAIN . '/wp-admin/term.php?taxonomy=wptests_tax&tag_ID=' . $term1 . '&post_type=post';
-               $this->assertSame( $expected, $actual );
-       }
-
-       /**
-        * @ticket 32786
-        */
-       public function test_get_edit_term_link_invalid_id() {
-               $term1 = self::factory()->term->create(
-                       array(
-                               'taxonomy' => 'wptests_tax',
-                               'name'     => 'foo',
-                       )
-               );
-
-               $actual = get_edit_term_link( 12345, 'wptests_tax' );
-               $this->assertNull( $actual );
-       }
-
-       /**
-        * @ticket 32786
-        */
-       public function test_get_edit_term_link_empty_id() {
-               $actual = get_edit_term_link( '', 'wptests_tax' );
-               $this->assertNull( $actual );
-       }
-
-       /**
-        * @ticket 32786
-        */
-       public function test_get_edit_term_link_bad_tax() {
-               $actual = get_edit_term_link( '', 'bad_tax' );
-               $this->assertNull( $actual );
-       }
-
-       /**
-        * @ticket 35922
-        */
-       public function test_taxonomy_should_not_be_required() {
-               $t = self::factory()->term->create(
-                       array(
-                               'taxonomy' => 'wptests_tax',
-                               'name'     => 'foo',
-                       )
-               );
-
-               $actual = get_edit_term_link( $t );
-               $this->assertNotNull( $actual );
-       }
-
-       /**
-        * @ticket 35922
-        */
-       public function test_cap_check_should_use_correct_taxonomy_when_taxonomy_is_not_specified() {
-               register_taxonomy(
-                       'wptests_tax_subscriber',
-                       'post',
-                       array(
-                               'capabilities' => array(
-                                       'edit_terms' => 'read',
-                               ),
-                       )
-               );
-
-               $t = self::factory()->term->create(
-                       array(
-                               'taxonomy' => 'wptests_tax_subscriber',
-                               'name'     => 'foo',
-                       )
-               );
-
-               $u = self::factory()->user->create(
-                       array(
-                               'role' => 'subscriber',
-                       )
-               );
-               wp_set_current_user( $u );
-
-               $actual = get_edit_term_link( $t );
-               $this->assertNotNull( $actual );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunitteststermgetTermLinkphp"></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/term/getTermLink.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getTermLink.php    2022-08-04 17:47:41 UTC (rev 53835)
+++ trunk/tests/phpunit/tests/term/getTermLink.php      2022-08-04 18:28:33 UTC (rev 53836)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,6 +22,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">                self::register_custom_taxonomy();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Helper to register a custom taxonomy for use in tests.
+        *
+        * @since 5.9.0
+        */
+       private static function register_custom_taxonomy() {
+               register_taxonomy( 'wptests_tax', 'post' );
+       }
+
+       /**
+        * Helper to get the term for the given taxonomy.
+        *
+        * @since 5.9.0
+        *
+        * @param string $taxonomy Taxonomy being tested (used for index of term keys).
+        * @param bool   $use_id   When true, pass term ID. Else, pass term object.
+        * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term.
+        */
+       private function get_term( $taxonomy, $use_id ) {
+               $term = self::$terms[ $taxonomy ];
+               if ( $use_id ) {
+                       $term = $term->term_id;
+               }
+
+               return $term;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         public function test_integer_should_be_interpreted_as_term_id() {
</span><span class="cx" style="display: block; padding: 0 10px">                $t1 = self::factory()->term->create(
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -320,31 +347,4 @@
</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">-
-       /**
-        * Helper to register a custom taxonomy for use in tests.
-        *
-        * @since 5.9.0
-        */
-       private static function register_custom_taxonomy() {
-               register_taxonomy( 'wptests_tax', 'post' );
-       }
-
-       /**
-        * Helper to get the term for the given taxonomy.
-        *
-        * @since 5.9.0
-        *
-        * @param string $taxonomy Taxonomy being tested (used for index of term keys).
-        * @param bool   $use_id   When true, pass term ID. Else, pass term object.
-        * @return WP_Term|int If $use_id is true, term ID is returned; else instance of WP_Term.
-        */
-       private function get_term( $taxonomy, $use_id ) {
-               $term = self::$terms[ $taxonomy ];
-               if ( $use_id ) {
-                       $term = $term->term_id;
-               }
-
-               return $term;
-       }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>