wordpress-develop/tests/phpunit/tests/category/getCatId.php
Sergey Biryukov 800ff4447c 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 [28438], [28566], [31006], [31025], [37464], [28438], [31299], [36988], [42364], [42367], [42368], [46413], [53684].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54717 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-29 14:38:18 +00:00

30 lines
570 B
PHP

<?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 ) );
}
}