Permalink
Browse files

add testSelectWithText()

  • Loading branch information...
1 parent 2f7f9a1 commit 94caceb75d7aefc917413763909f3216f1527ad2 @scribu committed Feb 21, 2013
Showing with 33 additions and 1 deletion.
  1. +33 −1 tests/test-forms.php
View
@@ -204,7 +204,7 @@ function testSelect() {
$label = self::domify( scbForms::input( $args ) )->find('//label');
- $this->assertStringEndsWith( 'Some extra text', $label->text() );
+ $this->assertStringEndsWith( $args['desc'], $label->text() );
$options = $label->find('.//select/option');
@@ -223,6 +223,38 @@ function testSelect() {
}
}
+ function testSelectWithText() {
+ $choices = array(
+ 'green' => 'Green',
+ 'blue' => 'Blue',
+ 'white' => 'White'
+ );
+
+ $args = array(
+ 'name' => __FUNCTION__,
+ 'type' => 'select',
+ 'choices' => $choices,
+ 'text' => 'Enter a color',
+ 'desc' => 'Some extra text',
+ );
+
+ $label = self::domify( scbForms::input( $args ) )->find('//label');
+
+ $this->assertStringEndsWith( $args['desc'], $label->text() );
+
+ $options = $label->find('.//select/option');
+
+ $this->assertCount( count( $choices ) + 1, $options );
+
+ $first_option = FluentDOM( $options->item(0) );
+
+ $this->assertEquals( $args['text'], $first_option->text() );
+
+ $this->assertEmpty( $first_option->attr('value') );
+
+ $this->assertNotEmpty( $first_option->attr('selected') );
+ }
+
function testSelectWithValue() {
$choices = array(
'1/2',

0 comments on commit 94caceb

Please sign in to comment.