From 131e542d013d6c1932bbf477d6eba031cebd0276 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 17 Dec 2020 00:01:06 +0100 Subject: Adds function for adding arbitrary locations and rewrites posttype and taxonomy to use this function as well --- tests/MetaboxTest.php | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'tests/MetaboxTest.php') diff --git a/tests/MetaboxTest.php b/tests/MetaboxTest.php index e26c9f2..319e4c0 100644 --- a/tests/MetaboxTest.php +++ b/tests/MetaboxTest.php @@ -36,39 +36,47 @@ class MetaboxTest extends TestCase /** * @test */ - public function assignsPostTypeOnce() + public function assignsPostType() { $this->metabox->posttype(['post', 'page']); - $expectedPostTypes = [ - 'post' => 'post', - 'page' => 'page', + $expectedLocations = [ + [ + 'param' => 'post_type', + 'operator' => '==', + 'value' => 'post' + ], + [ + 'param' => 'post_type', + 'operator' => '==', + 'value' => 'page' + ], ]; - $this->assertEquals($expectedPostTypes, $this->metabox->posttypes); - - $this->metabox->posttype('post'); - - $this->assertEquals($expectedPostTypes, $this->metabox->posttypes); + $this->assertEquals($expectedLocations, $this->metabox->locations); } /** * @test */ - public function assignsTaxonomyOnce() + public function assignsTaxonomy() { $this->metabox->taxonomy(['category', 'post_tag']); - $expectedTaxonomies = [ - 'category' => 'category', - 'post_tag' => 'post_tag', + $expectedLocations = [ + [ + 'param' => 'taxonomy', + 'operator' => '==', + 'value' => 'category' + ], + [ + 'param' => 'taxonomy', + 'operator' => '==', + 'value' => 'post_tag' + ], ]; - $this->assertEquals($expectedTaxonomies, $this->metabox->taxonomies); - - $this->metabox->taxonomy('category'); - - $this->assertEquals($expectedTaxonomies, $this->metabox->taxonomies); + $this->assertEquals($expectedLocations, $this->metabox->locations); } /** -- cgit v1.2.3