summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-05-24 19:33:07 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-05-24 19:33:07 +0200
commit9694c61f301989cdbbfd9e303e74b30812752cab (patch)
treec8985aec611358f08ea817f3e58487ffd708159d /tests
parentc65980879a990e6d02a8ab262b014e670f314477 (diff)
downloadgigologadmin-9694c61f301989cdbbfd9e303e74b30812752cab.tar.gz
gigologadmin-9694c61f301989cdbbfd9e303e74b30812752cab.tar.bz2
gigologadmin-9694c61f301989cdbbfd9e303e74b30812752cab.zip
Allow custom text for no selection in select_fields.
Diffstat (limited to 'tests')
-rw-r--r--tests/SelectFieldTest.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/SelectFieldTest.php b/tests/SelectFieldTest.php
index 1c1a8c2..fb6c298 100644
--- a/tests/SelectFieldTest.php
+++ b/tests/SelectFieldTest.php
@@ -22,6 +22,7 @@ final class SelectFieldTest extends WP_UnitTestCase
$res = ViewHelpers\select_field("fooselect", [[42, 'An option']]);
$this->assertStringStartsWith('<select name="fooselect">', $res);
$this->assertStringEndsWith('</select>', $res);
+ $this->assertStringContainsString('<option value="">Please select...</option>', $res);
$this->assertStringContainsString('<option value="42">An option</option>', $res);
}
@@ -33,6 +34,7 @@ final class SelectFieldTest extends WP_UnitTestCase
$this->assertStringStartsWith('<select name="fooselect">', $res);
$this->assertStringEndsWith('</select>', $res);
+ $this->assertStringContainsString('<option value="">Please select...</option>', $res);
$this->assertStringContainsString('<option value="42">An option</option>', $res);
$this->assertStringContainsString('<option value="666">Another option</option>', $res);
$this->assertStringContainsString('<option value="foo">A foo option</option>', $res);
@@ -46,6 +48,21 @@ final class SelectFieldTest extends WP_UnitTestCase
$this->assertStringStartsWith('<select name="fooselect">', $res);
$this->assertStringEndsWith('</select>', $res);
+ $this->assertStringContainsString('<option value="">Please select...</option>', $res);
+ $this->assertStringContainsString('<option value="42">An option</option>', $res);
+ $this->assertStringContainsString('<option value="666" selected=\'selected\'>Another option</option>', $res);
+ $this->assertStringContainsString('<option value="foo">A foo option</option>', $res);
+ }
+
+ public function testSelectFieldWithCustomBlankSelectionText()
+ {
+ $opts = [[42, 'An option'], [666, 'Another option'], ["foo", 'A foo option']];
+
+ $res = ViewHelpers\select_field("fooselect", $opts, 666, "None");
+
+ $this->assertStringStartsWith('<select name="fooselect">', $res);
+ $this->assertStringEndsWith('</select>', $res);
+ $this->assertStringContainsString('<option value="">None</option>', $res);
$this->assertStringContainsString('<option value="42">An option</option>', $res);
$this->assertStringContainsString('<option value="666" selected=\'selected\'>Another option</option>', $res);
$this->assertStringContainsString('<option value="foo">A foo option</option>', $res);