From 86a2c06f6fa0d59b004a4f20b8a7d4943e13d44b Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 20 Aug 2016 17:00:56 +0000 Subject: [PATCH] Introduce tests for `get_object_taxonomies()`. See #37368. git-svn-id: https://develop.svn.wordpress.org/trunk@38290 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/taxonomy/getObjectTaxonomies.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/phpunit/tests/taxonomy/getObjectTaxonomies.php diff --git a/tests/phpunit/tests/taxonomy/getObjectTaxonomies.php b/tests/phpunit/tests/taxonomy/getObjectTaxonomies.php new file mode 100644 index 0000000000..afe5655fd9 --- /dev/null +++ b/tests/phpunit/tests/taxonomy/getObjectTaxonomies.php @@ -0,0 +1,48 @@ +assertSame( $expected, $found ); + } + + public function test_object_should_accept_array_of_post_type_names() { + $found = get_object_taxonomies( array( 'wptests_pt' ) ); + $expected = array( 'wptests_tax' ); + + $this->assertSame( $expected, $found ); + } + + public function test_object_should_accept_post_object() { + $p = self::factory()->post->create_and_get( array( 'post_type' => 'wptests_pt' ) ); + $found = get_object_taxonomies( $p ); + $expected = array( 'wptests_tax' ); + + $this->assertSame( $expected, $found ); + } + + public function test_should_respect_output_names() { + $found = get_object_taxonomies( 'wptests_pt', 'objects' ); + + $this->assertSame( array( 'wptests_tax' ), array_keys( $found ) ); + $this->assertInternalType( 'object', $found['wptests_tax'] ); + $this->assertSame( 'wptests_tax', $found['wptests_tax']->name ); + } + + public function test_any_value_of_output_other_than_names_should_return_objects() { + $found = get_object_taxonomies( 'wptests_pt', 'foo' ); + $expected = get_object_taxonomies( 'wptests_pt', 'objects' ); + + $this->assertSame( $expected, $found ); + } +}