<!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>[55924] trunk/tests/phpunit/tests/term: Tests/Build tools: Various term related test improvements.</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/55924">55924</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/55924","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>peterwilsoncc</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-06-15 03:23:25 +0000 (Thu, 15 Jun 2023)</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/Build tools: Various term related test improvements.
Modifies the tests for `get_tag_link()`, `get_term()` and `get_term_field()` to:
- use shared fixtures as possible
- improves variable names
- add `@covers` annotation as required
Props peterwilsoncc, costdev.
See <a href="https://core.trac.wordpress.org/ticket/57841">#57841</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunitteststermgetTagLinkphp">trunk/tests/phpunit/tests/term/getTagLink.php</a></li>
<li><a href="#trunktestsphpunitteststermgetTermphp">trunk/tests/phpunit/tests/term/getTerm.php</a></li>
<li><a href="#trunktestsphpunitteststermgetTermFieldphp">trunk/tests/phpunit/tests/term/getTermField.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunitteststermgetTagLinkphp"></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/getTagLink.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getTagLink.php 2023-06-15 01:37:09 UTC (rev 55923)
+++ trunk/tests/phpunit/tests/term/getTagLink.php 2023-06-15 03:23:25 UTC (rev 55924)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,17 +5,57 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_tag_link
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Term_GetTagLink extends WP_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_success() {
- $t = self::factory()->term->create(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Tag ID.
+ *
+ * @var int
+ */
+ public static $tag_id;
+
+ /**
+ * Test taxonomy term ID.
+ *
+ * @var int
+ */
+ public static $term_id;
+
+ /**
+ * Set up shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$tag_id = $factory->term->create(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'taxonomy' => 'post_tag',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'slug' => 'term-slug',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'slug' => 'test-tag',
</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">- $found = get_tag_link( $t );
- $expected = home_url( '?tag=term-slug' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_taxonomy( 'wptests_tax', 'post' );
+ self::$term_id = self::factory()->term->create(
+ array(
+ 'taxonomy' => 'wptests_tax',
+ 'slug' => 'test-term',
+ )
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Set up the test fixture.
+ */
+ public function set_up() {
+ parent::set_up();
+ // Required as taxonomies are reset between tests.
+ register_taxonomy( 'wptests_tax', 'post' );
+ }
+
+ public function test_success() {
+ $tag_id = self::$tag_id;
+
+ $found = get_tag_link( $tag_id );
+ $expected = home_url( '?tag=test-tag' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $expected, $found );
</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">@@ -23,18 +63,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 42771
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_return_link_for_term_from_another_taxonomy_on_primed_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_taxonomy( 'wptests_tax', 'post' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create(
- array(
- 'taxonomy' => 'wptests_tax',
- 'slug' => 'test-term',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = get_term( $term_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = get_term( $t );
-
- $found = get_tag_link( $t );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_tag_link( $term_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected = home_url( '?wptests_tax=test-term' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $expected, $found );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,18 +77,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 42771
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_return_link_for_term_from_another_taxonomy_on_empty_cache() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_taxonomy( 'wptests_tax', 'post' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create(
- array(
- 'taxonomy' => 'wptests_tax',
- 'slug' => 'test-term',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_term_cache( $term_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- clean_term_cache( $t );
-
- $found = get_tag_link( $t );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_tag_link( $term_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $expected = home_url( '?wptests_tax=test-term' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $expected, $found );
</span></span></pre></div>
<a id="trunktestsphpunitteststermgetTermphp"></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/getTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getTerm.php 2023-06-15 01:37:09 UTC (rev 55923)
+++ trunk/tests/phpunit/tests/term/getTerm.php 2023-06-15 03:23:25 UTC (rev 55924)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,11 +2,44 @@
</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"> * @group taxonomy
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @covers ::get_term
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Term_GetTerm extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Shared terms.
+ *
+ * @var array[]
+ */
+ public static $shared_terms = array();
+
+ /**
+ * Test taxonomy term object.
+ *
+ * @var WP_Term
+ */
+ public static $term;
+
+ /**
+ * Set up shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ register_taxonomy( 'wptests_tax', 'post' );
+ self::$shared_terms = self::generate_shared_terms();
+
+ self::$term = $factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
+ }
+
+ /**
+ * Set up the test fixtures.
+ */
</ins><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">+ // Required as taxonomies are reset between tests.
</ins><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax', 'post' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_taxonomy( 'wptests_tax_2', '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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,35 +47,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Array of term_id/old_term_id/term_taxonomy_id triplets.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected function generate_shared_terms() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static function generate_shared_terms() {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'wptests_tax_2', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t1 = wp_insert_term( 'Foo', 'wptests_tax' );
- $t2 = wp_insert_term( 'Foo', 'wptests_tax_2' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_1 = wp_insert_term( 'Foo', 'wptests_tax' );
+ $term_2 = wp_insert_term( 'Foo', 'wptests_tax_2' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Manually modify because shared terms shouldn't naturally occur.
</span><span class="cx" style="display: block; padding: 0 10px"> $wpdb->update(
</span><span class="cx" style="display: block; padding: 0 10px"> $wpdb->term_taxonomy,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array( 'term_id' => $t1['term_id'] ),
- array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'term_id' => $term_1['term_id'] ),
+ array( 'term_taxonomy_id' => $term_2['term_taxonomy_id'] ),
</ins><span class="cx" style="display: block; padding: 0 10px"> array( '%d' ),
</span><span class="cx" style="display: block; padding: 0 10px"> array( '%d' )
</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">- clean_term_cache( $t1['term_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_term_cache( $term_1['term_id'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return array(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'term_id' => $t1['term_id'],
- 'old_term_id' => $t1['term_id'],
- 'term_taxonomy_id' => $t1['term_taxonomy_id'],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'term_id' => $term_1['term_id'],
+ 'old_term_id' => $term_1['term_id'],
+ 'term_taxonomy_id' => $term_1['term_taxonomy_id'],
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'term_id' => $t1['term_id'],
- 'old_term_id' => $t2['term_id'],
- 'term_taxonomy_id' => $t2['term_taxonomy_id'],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'term_id' => $term_1['term_id'],
+ 'old_term_id' => $term_2['term_id'],
+ 'term_taxonomy_id' => $term_2['term_taxonomy_id'],
</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">@@ -60,7 +93,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_passing_term_object_should_skip_database_query_when_filter_property_is_empty() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</ins><span class="cx" style="display: block; padding: 0 10px"> clean_term_cache( $term->term_id, 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $num_queries = get_num_queries();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,34 +113,34 @@
</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_cache_should_be_populated_by_successful_fetch() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
- clean_term_cache( $t, 'wptests_tax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term->term_id;
+ clean_term_cache( $term_id, 'wptests_tax' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term_a = get_term( $t, 'wptests_tax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_a = get_term( $term_id, 'wptests_tax' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $num_queries = get_num_queries();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Second call shouldn't require a database query.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term_b = get_term( $t, 'wptests_tax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_b = get_term( $term_id, 'wptests_tax' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $num_queries, get_num_queries() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $term_a, $term_b );
</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_output_object() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
- $this->assertIsObject( get_term( $t, 'wptests_tax', OBJECT ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term->term_id;
+ $this->assertIsObject( get_term( $term_id, 'wptests_tax', OBJECT ) );
</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_output_array_a() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
- $term = get_term( $t, 'wptests_tax', ARRAY_A );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term->term_id;
+ $term = get_term( $term_id, 'wptests_tax', ARRAY_A );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsArray( $term );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'term_id', $term );
</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_output_array_n() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
- $term = get_term( $t, 'wptests_tax', ARRAY_N );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term->term_id;
+ $term = get_term( $term_id, 'wptests_tax', ARRAY_N );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertIsArray( $term );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayNotHasKey( 'term_id', $term );
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $term as $k => $v ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -116,8 +149,8 @@
</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_output_should_fall_back_to_object_for_invalid_input() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
- $this->assertIsObject( get_term( $t, 'wptests_tax', 'foo' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term->term_id;
+ $this->assertIsObject( get_term( $term_id, 'wptests_tax', 'foo' ) );
</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">@@ -127,10 +160,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_numeric_properties_should_be_cast_to_ints() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term->term_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Get raw data from the database.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms t JOIN $wpdb->term_taxonomy tt ON ( t.term_id = tt.term_id ) WHERE t.term_id = %d", $t ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms t JOIN $wpdb->term_taxonomy tt ON ( t.term_id = tt.term_id ) WHERE t.term_id = %d", $term_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $contexts = array( 'raw', 'edit', 'db', 'display', 'rss', 'attribute', 'js' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,7 +183,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34332
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_return_null_when_provided_taxonomy_does_not_match_actual_term_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term_id = self::factory()->term->create( array( 'taxonomy' => 'post_tag' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term->term_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( get_term( $term_id, 'category' ) );
</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">@@ -158,7 +191,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34533
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_return_wp_error_when_term_is_shared_and_no_taxonomy_is_specified() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $this->generate_shared_terms();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = self::$shared_terms;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_term( $terms[0]['term_id'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -169,7 +202,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34533
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_return_term_when_term_is_shared_and_correct_taxonomy_is_specified() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $this->generate_shared_terms();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = self::$shared_terms;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_term( $terms[0]['term_id'], 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -181,7 +214,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34533
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_return_null_when_term_is_shared_and_incorrect_taxonomy_is_specified() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $this->generate_shared_terms();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = self::$shared_terms;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_term( $terms[0]['term_id'], 'post_tag' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,7 +225,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34533
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_shared_term_in_cache_should_be_ignored_when_specifying_a_different_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $this->generate_shared_terms();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = self::$shared_terms;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime cache for 'wptests_tax'.
</span><span class="cx" style="display: block; padding: 0 10px"> get_term( $terms[0]['term_id'], 'wptests_tax' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -211,11 +244,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34533
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_should_return_error_when_only_matching_term_is_in_an_invalid_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_id = self::$term->term_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> _unregister_taxonomy( 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = get_term( $t );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_term( $term_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertWPError( $found );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'invalid_taxonomy', $found->get_error_code() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -224,7 +257,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34533
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_term_should_be_returned_when_id_is_shared_only_with_invalid_taxonomies() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $this->generate_shared_terms();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = self::$shared_terms;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> _unregister_taxonomy( 'wptests_tax' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunitteststermgetTermFieldphp"></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/getTermField.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/getTermField.php 2023-06-15 01:37:09 UTC (rev 55923)
+++ trunk/tests/phpunit/tests/term/getTermField.php 2023-06-15 03:23:25 UTC (rev 55924)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,15 +2,34 @@
</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"> * @group taxonomy
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @covers ::get_term_field
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Term_getTermField extends WP_UnitTestCase {
</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 $taxonomy = 'wptests_tax';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static $taxonomy = 'wptests_tax';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static $term;
+
+ /**
+ * Set up shared fixtures.
+ *
+ * @param WP_UnitTest_Factory $factory
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ register_taxonomy( self::$taxonomy, 'post' );
+ self::$term = $factory->term->create_and_get(
+ array(
+ 'taxonomy' => self::$taxonomy,
+ 'description' => wpautop( 'Test term description' ),
+ )
+ );
+ }
+
</ins><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- register_taxonomy( $this->taxonomy, 'post' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Required as taxonomies are reset between tests.
+ register_taxonomy( self::$taxonomy, '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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,11 +36,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34245
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_field_should_not_return_error_for_empty_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_term_field( 'taxonomy', $term->term_id, '' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $found );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->taxonomy, $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::$taxonomy, $found );
</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">@@ -28,10 +47,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34245
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_field_supplying_a_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_term_field( 'taxonomy', $term->term_id, $term->taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->taxonomy, $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::$taxonomy, $found );
</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">@@ -38,10 +57,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34245
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_field_supplying_no_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_term_field( 'taxonomy', $term->term_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->taxonomy, $found );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::$taxonomy, $found );
</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">@@ -48,7 +67,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34245
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_field_should_accept_a_WP_Term_id_or_object() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_Term', $term );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $term->term_id, get_term_field( 'term_id', $term ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,7 +79,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34245
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_field_invalid_taxonomy_should_return_WP_Error() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $found = get_term_field( 'taxonomy', $term, 'foo-taxonomy' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertWPError( $found );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -71,7 +90,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 34245
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_field_invalid_term_should_return_WP_Error() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = get_term_field( 'taxonomy', 0, $this->taxonomy );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = get_term_field( 'taxonomy', 0, self::$taxonomy );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertWPError( $found );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'invalid_term', $found->get_error_code() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -83,7 +102,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_get_term_field_term_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $term->term_id, get_term_field( 'term_id', $term ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $term->term_id, get_term_field( 'term_id', $term->data ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,7 +115,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create_and_get(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'name' => $name,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'taxonomy' => $this->taxonomy,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'taxonomy' => self::$taxonomy,
</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">@@ -110,7 +129,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create_and_get(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'taxonomy' => $this->taxonomy,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'taxonomy' => self::$taxonomy,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'slug' => $slug,
</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">@@ -125,7 +144,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create_and_get(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'taxonomy' => $this->taxonomy,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'taxonomy' => self::$taxonomy,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'name' => $name,
</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">@@ -138,7 +157,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_term_field_slug_when_slug_and_name_are_not_set() {
</span><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create_and_get(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'taxonomy' => $this->taxonomy,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'taxonomy' => self::$taxonomy,
</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">@@ -148,33 +167,28 @@
</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_get_term_field_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</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( $this->taxonomy, get_term_field( 'taxonomy', $term ) );
- $this->assertSame( $this->taxonomy, get_term_field( 'taxonomy', $term->data ) );
- $this->assertSame( $this->taxonomy, get_term_field( 'taxonomy', $term->term_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::$taxonomy, get_term_field( 'taxonomy', $term ) );
+ $this->assertSame( self::$taxonomy, get_term_field( 'taxonomy', $term->data ) );
+ $this->assertSame( self::$taxonomy, get_term_field( 'taxonomy', $term->term_id ) );
</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_get_term_field_description() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $desc = wpautop( 'baz' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $description = wpautop( 'Test term description' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = self::factory()->term->create_and_get(
- array(
- 'taxonomy' => $this->taxonomy,
- 'description' => $desc,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = self::$term;
</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( $desc, get_term_field( 'description', $term ) );
- $this->assertSame( $desc, get_term_field( 'description', $term->data ) );
- $this->assertSame( $desc, get_term_field( 'description', $term->term_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $description, get_term_field( 'description', $term ) );
+ $this->assertSame( $description, get_term_field( 'description', $term->data ) );
+ $this->assertSame( $description, get_term_field( 'description', $term->term_id ) );
</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_get_term_field_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parent = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parent = self::$term;
</ins><span class="cx" style="display: block; padding: 0 10px"> $term = self::factory()->term->create_and_get(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'taxonomy' => $this->taxonomy,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'taxonomy' => self::$taxonomy,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'parent' => $parent->term_id,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span></span></pre>
</div>
</div>
</body>
</html>