<!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>[54717] trunk/tests/phpunit/tests: Tests: Split the tests from `category.php` into individual test classes.</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/54717">54717</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/54717","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-10-29 14:38:18 +0000 (Sat, 29 Oct 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: Split the tests from `category.php` into individual test classes.

This aims to bring some consistency to the location of category function tests, as well as to make the tests more discoverable and easier to expand.

Follow-up to <a href="https://core.trac.wordpress.org/changeset/28438">[28438]</a>, <a href="https://core.trac.wordpress.org/changeset/28566">[28566]</a>, <a href="https://core.trac.wordpress.org/changeset/31006">[31006]</a>, <a href="https://core.trac.wordpress.org/changeset/31025">[31025]</a>, <a href="https://core.trac.wordpress.org/changeset/37464">[37464]</a>, <a href="https://core.trac.wordpress.org/changeset/28438">[28438]</a>, <a href="https://core.trac.wordpress.org/changeset/31299">[31299]</a>, <a href="https://core.trac.wordpress.org/changeset/36988">[36988]</a>, <a href="https://core.trac.wordpress.org/changeset/42364">[42364]</a>, <a href="https://core.trac.wordpress.org/changeset/42367">[42367]</a>, <a href="https://core.trac.wordpress.org/changeset/42368">[42368]</a>, <a href="https://core.trac.wordpress.org/changeset/46413">[46413]</a>, <a href="https://core.trac.wordpress.org/changeset/53684">[53684]</a>.

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

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestscategorygetAllCategoryIdsphp">trunk/tests/phpunit/tests/category/getAllCategoryIds.php</a></li>
<li><a href="#trunktestsphpunittestscategorygetCatIdphp">trunk/tests/phpunit/tests/category/getCatId.php</a></li>
<li><a href="#trunktestsphpunittestscategorygetCatNamephp">trunk/tests/phpunit/tests/category/getCatName.php</a></li>
<li><a href="#trunktestsphpunittestscategorygetCategoryByPathphp">trunk/tests/phpunit/tests/category/getCategoryByPath.php</a></li>
<li><a href="#trunktestsphpunittestscategorygetCategoryBySlugphp">trunk/tests/phpunit/tests/category/getCategoryBySlug.php</a></li>
<li><a href="#trunktestsphpunittestscategorymakeCatCompatphp">trunk/tests/phpunit/tests/category/makeCatCompat.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestscategoryphp">trunk/tests/phpunit/tests/category.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestscategorygetAllCategoryIdsphpfromrev54642trunktestsphpunittestscategoryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/category/getAllCategoryIds.php (from rev 54642, trunk/tests/phpunit/tests/category.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/category/getAllCategoryIds.php                          (rev 0)
+++ trunk/tests/phpunit/tests/category/getAllCategoryIds.php    2022-10-29 14:38:18 UTC (rev 54717)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,30 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group taxonomy
+ * @group category.php
+ *
+ * @covers ::get_all_category_ids
+ */
+class Tests_Category_GetAllCategoryIds extends WP_UnitTestCase {
+
+       /**
+        * Validate get_all_category_ids
+        *
+        * @expectedDeprecated get_all_category_ids
+        */
+       public function test_get_all_category_ids() {
+               // Ccreate categories.
+               self::factory()->category->create_many( 2 );
+
+               // Create new taxonomy to ensure not included.
+               register_taxonomy( 'test_tax_cat', 'post' );
+
+               wp_insert_term( 'test1', 'test_tax_cat' );
+               $cat_ids = get_all_category_ids();
+
+               _unregister_taxonomy( 'test_tax_cat' );
+
+               // Validate length is 1 + created due to uncategorized.
+               $this->assertCount( 3, $cat_ids );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestscategorygetCatIdphpfromrev54642trunktestsphpunittestscategoryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/category/getCatId.php (from rev 54642, trunk/tests/phpunit/tests/category.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/category/getCatId.php                           (rev 0)
+++ trunk/tests/phpunit/tests/category/getCatId.php     2022-10-29 14:38:18 UTC (rev 54717)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,29 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group taxonomy
+ * @group category.php
+ *
+ * @covers ::get_cat_ID
+ */
+class Tests_Category_GetCatId extends WP_UnitTestCase {
+
+       /**
+        * Validate get_cat_ID function
+        */
+       public function test_get_cat_ID() {
+
+               // Create test category.
+               $testcat = self::factory()->category->create_and_get(
+                       array(
+                               'slug' => 'testcat',
+                               'name' => 'Test Category 1',
+                       )
+               );
+
+               // Validate.
+               $this->assertSame( $testcat->term_id, get_cat_ID( $testcat->name ) );
+               $this->assertSame( 0, get_cat_ID( 'NO CAT' ) );
+               $this->assertSame( 0, get_cat_ID( 12 ) );
+
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestscategorygetCatNamephpfromrev54642trunktestsphpunittestscategoryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/category/getCatName.php (from rev 54642, trunk/tests/phpunit/tests/category.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/category/getCatName.php                         (rev 0)
+++ trunk/tests/phpunit/tests/category/getCatName.php   2022-10-29 14:38:18 UTC (rev 54717)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,29 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group taxonomy
+ * @group category.php
+ *
+ * @covers ::get_cat_name
+ */
+class Tests_Category_GetCatName extends WP_UnitTestCase {
+
+       /**
+        * Validate get_cat_name function
+        */
+       public function test_get_cat_name() {
+
+               // Create test category.
+               $testcat = self::factory()->category->create_and_get(
+                       array(
+                               'slug' => 'testcat',
+                               'name' => 'Test Category 1',
+                       )
+               );
+
+               // Validate.
+               $this->assertSame( $testcat->name, get_cat_name( $testcat->term_id ) );
+               $this->assertSame( '', get_cat_name( -1 ) );
+               $this->assertSame( '', get_cat_name( $testcat->term_id + 100 ) );
+
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestscategorygetCategoryByPathphpfromrev54642trunktestsphpunittestscategoryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/category/getCategoryByPath.php (from rev 54642, trunk/tests/phpunit/tests/category.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/category/getCategoryByPath.php                          (rev 0)
+++ trunk/tests/phpunit/tests/category/getCategoryByPath.php    2022-10-29 14:38:18 UTC (rev 54717)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,73 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group taxonomy
+ * @group category.php
+ *
+ * @covers ::get_category_by_path
+ */
+class Tests_Category_GetCategoryByPath extends WP_UnitTestCase {
+
+       /**
+        * Validate get_category_by_path function
+        */
+       public function test_get_category_by_path() {
+
+               // Create test categories.
+               $root_id           = self::factory()->category->create(
+                       array(
+                               'slug' => 'root',
+                       )
+               );
+               $root_cat_id       = self::factory()->category->create(
+                       array(
+                               'slug'   => 'cat',
+                               'parent' => $root_id,
+                       )
+               );
+               $root_cat_cat_id   = self::factory()->category->create(
+                       array(
+                               'slug'   => 'cat', // Note this is modified on create.
+                               'parent' => $root_cat_id,
+                       )
+               );
+               $root_path_id      = self::factory()->category->create(
+                       array(
+                               'slug'   => 'path',
+                               'parent' => $root_id,
+                       )
+               );
+               $root_path_cat_id  = self::factory()->category->create(
+                       array(
+                               'slug'   => 'cat', // Note this is modified on create.
+                               'parent' => $root_path_id,
+                       )
+               );
+               $root_level_id     = self::factory()->category->create(
+                       array(
+                               'slug'   => 'level-1',
+                               'parent' => $root_id,
+                       )
+               );
+               $root_level_cat_id = self::factory()->category->create(
+                       array(
+                               'slug'   => 'cat', // Note this is modified on create.
+                               'parent' => $root_level_id,
+                       )
+               );
+
+               // Validate full match.
+               $ret_cat = get_category_by_path( '/root/level-1', true );
+               $this->assertSame( $root_level_id, $ret_cat->term_id );
+               $this->assertNull( get_category_by_path( 'level-1', true ) );
+               $this->assertNull( get_category_by_path( 'nocat/nocat/', true ) );
+
+               // Validate partial match.
+               $ret_cat = get_category_by_path( 'level-1', false );
+               $this->assertSame( $root_level_id, $ret_cat->term_id );
+               $ret_cat = get_category_by_path( 'root/cat/level-1', false );
+               $this->assertSame( $root_level_id, $ret_cat->term_id );
+               $ret_cat = get_category_by_path( 'root$2Fcat%20%2Flevel-1', false );
+               $this->assertSame( $root_level_id, $ret_cat->term_id );
+               $this->assertNull( get_category_by_path( 'nocat/nocat/', false ) );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestscategorygetCategoryBySlugphpfromrev54642trunktestsphpunittestscategoryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/category/getCategoryBySlug.php (from rev 54642, trunk/tests/phpunit/tests/category.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/category/getCategoryBySlug.php                          (rev 0)
+++ trunk/tests/phpunit/tests/category/getCategoryBySlug.php    2022-10-29 14:38:18 UTC (rev 54717)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,39 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group taxonomy
+ * @group category.php
+ *
+ * @covers ::get_category_by_slug
+ */
+class Tests_Category_GetCategoryBySlug extends WP_UnitTestCase {
+
+       /**
+        * Validate get_category_by_slug function
+        */
+       public function test_get_category_by_slug() {
+
+               // Create test categories.
+               $testcat  = self::factory()->category->create_and_get(
+                       array(
+                               'slug' => 'testcat',
+                               'name' => 'Test Category 1',
+                       )
+               );
+               $testcat2 = self::factory()->category->create_and_get(
+                       array(
+                               'slug' => 'testcat2',
+                               'name' => 'Test Category 2',
+                       )
+               );
+
+               // Validate category is returned by slug.
+               $ret_testcat = get_category_by_slug( 'testcat' );
+               $this->assertSame( $testcat->term_id, $ret_testcat->term_id );
+               $ret_testcat = get_category_by_slug( 'TeStCaT' );
+               $this->assertSame( $testcat->term_id, $ret_testcat->term_id );
+
+               // Validate unknown category returns false.
+               $this->assertFalse( get_category_by_slug( 'testcat3' ) );
+
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestscategorymakeCatCompatphpfromrev54642trunktestsphpunittestscategoryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/category/makeCatCompat.php (from rev 54642, trunk/tests/phpunit/tests/category.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/category/makeCatCompat.php                              (rev 0)
+++ trunk/tests/phpunit/tests/category/makeCatCompat.php        2022-10-29 14:38:18 UTC (rev 54717)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,86 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group taxonomy
+ * @group category.php
+ *
+ * @covers ::_make_cat_compat
+ */
+class Tests_Category_MakeCatCompat extends WP_UnitTestCase {
+
+       /**
+        * Validate _make_cat_compat function
+        */
+       public function test__make_cat_compat() {
+
+               // Create test categories and array representations.
+               $testcat_array            = array(
+                       'slug'        => 'testmcc',
+                       'name'        => 'Test MCC',
+                       'description' => 'Category Test',
+               );
+               $testcat                  = self::factory()->category->create_and_get( $testcat_array );
+               $testcat_array['term_id'] = $testcat->term_id;
+
+               $testcat2_array            = array(
+                       'slug'        => 'testmcc',
+                       'name'        => 'Test MCC',
+                       'description' => 'Category Test',
+                       'parent'      => $testcat->term_id,
+               );
+               $testcat2                  = self::factory()->category->create_and_get( $testcat2_array );
+               $testcat2_array['term_id'] = $testcat2->term_id;
+
+               // Unset properties to enable validation of object.
+               unset( $testcat->cat_ID );
+               unset( $testcat->category_count );
+               unset( $testcat->category_description );
+               unset( $testcat->cat_name );
+               unset( $testcat->category_nicename );
+               unset( $testcat->category_parent );
+
+               unset( $testcat2->cat_ID );
+               unset( $testcat2->category_count );
+               unset( $testcat2->category_description );
+               unset( $testcat2->cat_name );
+               unset( $testcat2->category_nicename );
+               unset( $testcat2->category_parent );
+
+               // Make compatible.
+               _make_cat_compat( $testcat );
+               _make_cat_compat( $testcat2 );
+               _make_cat_compat( $testcat_array );
+               _make_cat_compat( $testcat2_array );
+
+               // Validate compatibility object.
+               $this->assertSame( $testcat->cat_ID, $testcat->term_id );
+               $this->assertSame( $testcat->category_count, $testcat->count );
+               $this->assertSame( $testcat->category_description, $testcat->description );
+               $this->assertSame( $testcat->cat_name, $testcat->name );
+               $this->assertSame( $testcat->category_nicename, $testcat->slug );
+               $this->assertSame( $testcat->category_parent, $testcat->parent );
+
+               // Validate compatibility object with parent.
+               $this->assertSame( $testcat->cat_ID, $testcat->term_id );
+               $this->assertSame( $testcat->category_count, $testcat->count );
+               $this->assertSame( $testcat->category_description, $testcat->description );
+               $this->assertSame( $testcat->cat_name, $testcat->name );
+               $this->assertSame( $testcat->category_nicename, $testcat->slug );
+               $this->assertSame( $testcat->category_parent, $testcat->parent );
+
+               // Validate compatibility array.
+               $this->assertSame( $testcat_array['cat_ID'], $testcat_array['term_id'] );
+               $this->assertSame( $testcat_array['category_count'], $testcat_array['count'] );
+               $this->assertSame( $testcat_array['category_description'], $testcat_array['description'] );
+               $this->assertSame( $testcat_array['cat_name'], $testcat_array['name'] );
+               $this->assertSame( $testcat_array['category_nicename'], $testcat_array['slug'] );
+               $this->assertSame( $testcat_array['category_parent'], $testcat_array['parent'] );
+
+               // Validate compatibility array with parent.
+               $this->assertSame( $testcat_array['cat_ID'], $testcat_array['term_id'] );
+               $this->assertSame( $testcat_array['category_count'], $testcat_array['count'] );
+               $this->assertSame( $testcat_array['category_description'], $testcat_array['description'] );
+               $this->assertSame( $testcat_array['cat_name'], $testcat_array['name'] );
+               $this->assertSame( $testcat_array['category_nicename'], $testcat_array['slug'] );
+               $this->assertSame( $testcat_array['category_parent'], $testcat_array['parent'] );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestscategoryphp"></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/category.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/category.php    2022-10-29 13:39:05 UTC (rev 54716)
+++ trunk/tests/phpunit/tests/category.php      2022-10-29 14:38:18 UTC (rev 54717)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,257 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * Validate Category API
- *
- * Notes:
- * cat_is_ancestor_of is validated under test\term\term_is_ancestor_of
- *
- * @group category.php
- */
-class Tests_Category extends WP_UnitTestCase {
-
-       public function tear_down() {
-               _unregister_taxonomy( 'test_tax_cat' );
-               parent::tear_down();
-       }
-
-       /**
-        * Validate get_all_category_ids
-        *
-        * @expectedDeprecated get_all_category_ids
-        *
-        * @covers ::get_all_category_ids
-        */
-       public function test_get_all_category_ids() {
-               // Ccreate categories.
-               self::factory()->category->create_many( 2 );
-
-               // Create new taxonomy to ensure not included.
-               register_taxonomy( 'test_tax_cat', 'post' );
-               wp_insert_term( 'test1', 'test_tax_cat' );
-
-               // Validate length is 1 + created due to uncategorized.
-               $cat_ids = get_all_category_ids();
-               $this->assertCount( 3, $cat_ids );
-       }
-
-       /**
-        * Validate get_category_by_slug function
-        *
-        * @covers ::get_category_by_slug
-        */
-       public function test_get_category_by_slug() {
-
-               // Create test categories.
-               $testcat  = self::factory()->category->create_and_get(
-                       array(
-                               'slug' => 'testcat',
-                               'name' => 'Test Category 1',
-                       )
-               );
-               $testcat2 = self::factory()->category->create_and_get(
-                       array(
-                               'slug' => 'testcat2',
-                               'name' => 'Test Category 2',
-                       )
-               );
-
-               // Validate category is returned by slug.
-               $ret_testcat = get_category_by_slug( 'testcat' );
-               $this->assertSame( $testcat->term_id, $ret_testcat->term_id );
-               $ret_testcat = get_category_by_slug( 'TeStCaT' );
-               $this->assertSame( $testcat->term_id, $ret_testcat->term_id );
-
-               // Validate unknown category returns false.
-               $this->assertFalse( get_category_by_slug( 'testcat3' ) );
-
-       }
-
-       /**
-        * Validate _make_cat_compat function
-        *
-        * @covers ::_make_cat_compat
-        */
-       public function test__make_cat_compat() {
-
-               // Create test categories and array representations.
-               $testcat_array            = array(
-                       'slug'        => 'testmcc',
-                       'name'        => 'Test MCC',
-                       'description' => 'Category Test',
-               );
-               $testcat                  = self::factory()->category->create_and_get( $testcat_array );
-               $testcat_array['term_id'] = $testcat->term_id;
-
-               $testcat2_array            = array(
-                       'slug'        => 'testmcc',
-                       'name'        => 'Test MCC',
-                       'description' => 'Category Test',
-                       'parent'      => $testcat->term_id,
-               );
-               $testcat2                  = self::factory()->category->create_and_get( $testcat2_array );
-               $testcat2_array['term_id'] = $testcat2->term_id;
-
-               // Unset properties to enable validation of object.
-               unset( $testcat->cat_ID );
-               unset( $testcat->category_count );
-               unset( $testcat->category_description );
-               unset( $testcat->cat_name );
-               unset( $testcat->category_nicename );
-               unset( $testcat->category_parent );
-
-               unset( $testcat2->cat_ID );
-               unset( $testcat2->category_count );
-               unset( $testcat2->category_description );
-               unset( $testcat2->cat_name );
-               unset( $testcat2->category_nicename );
-               unset( $testcat2->category_parent );
-
-               // Make compatible.
-               _make_cat_compat( $testcat );
-               _make_cat_compat( $testcat2 );
-               _make_cat_compat( $testcat_array );
-               _make_cat_compat( $testcat2_array );
-
-               // Validate compatibility object.
-               $this->assertSame( $testcat->cat_ID, $testcat->term_id );
-               $this->assertSame( $testcat->category_count, $testcat->count );
-               $this->assertSame( $testcat->category_description, $testcat->description );
-               $this->assertSame( $testcat->cat_name, $testcat->name );
-               $this->assertSame( $testcat->category_nicename, $testcat->slug );
-               $this->assertSame( $testcat->category_parent, $testcat->parent );
-
-               // Validate compatibility object with parent.
-               $this->assertSame( $testcat->cat_ID, $testcat->term_id );
-               $this->assertSame( $testcat->category_count, $testcat->count );
-               $this->assertSame( $testcat->category_description, $testcat->description );
-               $this->assertSame( $testcat->cat_name, $testcat->name );
-               $this->assertSame( $testcat->category_nicename, $testcat->slug );
-               $this->assertSame( $testcat->category_parent, $testcat->parent );
-
-               // Validate compatibility array.
-               $this->assertSame( $testcat_array['cat_ID'], $testcat_array['term_id'] );
-               $this->assertSame( $testcat_array['category_count'], $testcat_array['count'] );
-               $this->assertSame( $testcat_array['category_description'], $testcat_array['description'] );
-               $this->assertSame( $testcat_array['cat_name'], $testcat_array['name'] );
-               $this->assertSame( $testcat_array['category_nicename'], $testcat_array['slug'] );
-               $this->assertSame( $testcat_array['category_parent'], $testcat_array['parent'] );
-
-               // Validate compatibility array with parent.
-               $this->assertSame( $testcat_array['cat_ID'], $testcat_array['term_id'] );
-               $this->assertSame( $testcat_array['category_count'], $testcat_array['count'] );
-               $this->assertSame( $testcat_array['category_description'], $testcat_array['description'] );
-               $this->assertSame( $testcat_array['cat_name'], $testcat_array['name'] );
-               $this->assertSame( $testcat_array['category_nicename'], $testcat_array['slug'] );
-               $this->assertSame( $testcat_array['category_parent'], $testcat_array['parent'] );
-       }
-
-       /**
-        * Validate get_cat_name function
-        *
-        * @covers ::get_cat_name
-        */
-       public function test_get_cat_name() {
-
-               // Create test category.
-               $testcat = self::factory()->category->create_and_get(
-                       array(
-                               'slug' => 'testcat',
-                               'name' => 'Test Category 1',
-                       )
-               );
-
-               // Validate.
-               $this->assertSame( $testcat->name, get_cat_name( $testcat->term_id ) );
-               $this->assertSame( '', get_cat_name( -1 ) );
-               $this->assertSame( '', get_cat_name( $testcat->term_id + 100 ) );
-
-       }
-
-       /**
-        * Validate get_cat_name function
-        *
-        * @covers ::get_cat_ID
-        */
-       public function test_get_cat_ID() {
-
-               // Create test category.
-               $testcat = self::factory()->category->create_and_get(
-                       array(
-                               'slug' => 'testcat',
-                               'name' => 'Test Category 1',
-                       )
-               );
-
-               // Validate.
-               $this->assertSame( $testcat->term_id, get_cat_ID( $testcat->name ) );
-               $this->assertSame( 0, get_cat_ID( 'NO CAT' ) );
-               $this->assertSame( 0, get_cat_ID( 12 ) );
-
-       }
-
-       /**
-        * Validate get_category_by_path function
-        *
-        * @covers ::get_category_by_path
-        */
-       public function test_get_category_by_path() {
-
-               // Create test categories.
-               $root_id           = self::factory()->category->create(
-                       array(
-                               'slug' => 'root',
-                       )
-               );
-               $root_cat_id       = self::factory()->category->create(
-                       array(
-                               'slug'   => 'cat',
-                               'parent' => $root_id,
-                       )
-               );
-               $root_cat_cat_id   = self::factory()->category->create(
-                       array(
-                               'slug'   => 'cat', // Note this is modified on create.
-                               'parent' => $root_cat_id,
-                       )
-               );
-               $root_path_id      = self::factory()->category->create(
-                       array(
-                               'slug'   => 'path',
-                               'parent' => $root_id,
-                       )
-               );
-               $root_path_cat_id  = self::factory()->category->create(
-                       array(
-                               'slug'   => 'cat', // Note this is modified on create.
-                               'parent' => $root_path_id,
-                       )
-               );
-               $root_level_id     = self::factory()->category->create(
-                       array(
-                               'slug'   => 'level-1',
-                               'parent' => $root_id,
-                       )
-               );
-               $root_level_cat_id = self::factory()->category->create(
-                       array(
-                               'slug'   => 'cat', // Note this is modified on create.
-                               'parent' => $root_level_id,
-                       )
-               );
-
-               // Validate full match.
-               $ret_cat = get_category_by_path( '/root/level-1', true );
-               $this->assertSame( $root_level_id, $ret_cat->term_id );
-               $this->assertNull( get_category_by_path( 'level-1', true ) );
-               $this->assertNull( get_category_by_path( 'nocat/nocat/', true ) );
-
-               // Validate partial match.
-               $ret_cat = get_category_by_path( 'level-1', false );
-               $this->assertSame( $root_level_id, $ret_cat->term_id );
-               $ret_cat = get_category_by_path( 'root/cat/level-1', false );
-               $this->assertSame( $root_level_id, $ret_cat->term_id );
-               $ret_cat = get_category_by_path( 'root$2Fcat%20%2Flevel-1', false );
-               $this->assertSame( $root_level_id, $ret_cat->term_id );
-               $this->assertNull( get_category_by_path( 'nocat/nocat/', false ) );
-       }
-}
</del></span></pre>
</div>
</div>

</body>
</html>