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