From 3195d4785e505f664898b6d5599c844832fa9734 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 16 Dec 2020 21:05:39 +0100 Subject: Fixes field reference in foreach loop --- tests/MetaboxTest.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/MetaboxTest.php b/tests/MetaboxTest.php index d5a27a3..1a1353e 100644 --- a/tests/MetaboxTest.php +++ b/tests/MetaboxTest.php @@ -22,7 +22,7 @@ class MetaboxTest extends TestCase protected function setUp(): void { $this->metabox = new Metabox('Test Metabox'); - $this->field = new MetaboxField('Test Field'); + $this->field = new MetaboxField('test_field'); } /** @@ -62,4 +62,22 @@ class MetaboxTest extends TestCase $this->assertEquals($this->field->parent, $this->metabox->key); $this->assertEquals($this->metabox->fields[$this->field->key], $this->field); } + + /** + * @test + */ + public function addsMultipleFieldsAsArray() + { + $fields = [ + $this->field, + $field2 = (new MetaboxField('field_2')), + ]; + $this->metabox->field($fields); + + $expected = [ + $this->field->key => $this->field, + $field2->key => $field2, + ]; + $this->assertEquals($expected, $this->metabox->fields); + } } -- cgit v1.2.3