From d6fabbd1e2396e9fb68e7cc8a4ea23417cc7d763 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 16 Dec 2020 19:12:18 +0100 Subject: Initial commit --- tests/MetaboxTest.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/MetaboxTest.php (limited to 'tests/MetaboxTest.php') diff --git a/tests/MetaboxTest.php b/tests/MetaboxTest.php new file mode 100644 index 0000000..d5a27a3 --- /dev/null +++ b/tests/MetaboxTest.php @@ -0,0 +1,65 @@ +metabox = new Metabox('Test Metabox'); + $this->field = new MetaboxField('Test Field'); + } + + /** + * @test + */ + public function hasGroupKeyOnInstantiation() + { + $this->assertEquals('group_test_metabox', $this->metabox->key); + } + + /** + * @test + */ + public function assignsPostTypeOnce() + { + $this->metabox->posttype(['post', 'page']); + + $expectedPostTypes = [ + 'post' => 'post', + 'page' => 'page', + ]; + + $this->assertEquals($expectedPostTypes, $this->metabox->posttypes); + + $this->metabox->posttype('post'); + + $this->assertEquals($expectedPostTypes, $this->metabox->posttypes); + } + + /** + * @test + */ + public function modifiesAndHoldsPassedField() + { + $this->metabox->field($this->field); + + $this->assertEquals($this->field->parent, $this->metabox->key); + $this->assertEquals($this->metabox->fields[$this->field->key], $this->field); + } +} -- cgit v1.2.3