Skip to content

Commit

Permalink
test description for <select> elements
Browse files Browse the repository at this point in the history
  • Loading branch information
scribu committed Feb 21, 2013
1 parent c1d6c45 commit 986e48f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/test-forms.php
Expand Up @@ -138,15 +138,11 @@ function testCheckboxWithValues() {
$selected = array( 'a', 'c' ); $selected = array( 'a', 'c' );
$choices = array( 'a', 'b', 'c', 'd' ); $choices = array( 'a', 'b', 'c', 'd' );


$data = array( $output = scbForms::input_with_value( array(
__FUNCTION__ => $selected
);

$output = scbForms::input( array(
'name' => __FUNCTION__, 'name' => __FUNCTION__,
'type' => 'checkbox', 'type' => 'checkbox',
'choices' => $choices 'choices' => $choices
), $data ); ), $selected );


$labels = self::domify( $output )->find('//label'); $labels = self::domify( $output )->find('//label');


Expand Down Expand Up @@ -183,12 +179,15 @@ function testSelect() {
'name' => __FUNCTION__, 'name' => __FUNCTION__,
'type' => 'select', 'type' => 'select',
'choices' => $choices, 'choices' => $choices,
'desc' => 'Some extra text'
); );


// no pre-selected value // no pre-selected value
$fd = self::domify( scbForms::input( $args ) ); $label = self::domify( scbForms::input( $args ) )->find('//label');

$this->assertStringEndsWith( 'Some extra text', $label->text() );


$options = $fd->find('//select/option'); $options = $label->find('.//select/option');


$this->assertCount( count( $choices ), $options ); $this->assertCount( count( $choices ), $options );


Expand All @@ -203,9 +202,9 @@ function testSelect() {
} }


// pre-select a value // pre-select a value
$fd = self::domify( scbForms::input( array_merge( $args, array( 'selected' => '1 1/3' ) ) ) ); $label = self::domify( scbForms::input( array_merge( $args, array( 'selected' => '1 1/3' ) ) ) )->find('//label');


$selected = $fd->find('//select/option[@selected]'); $selected = $label->find('.//select/option[@selected]');


$this->assertCount( 1, $selected ); $this->assertCount( 1, $selected );


Expand Down

0 comments on commit 986e48f

Please sign in to comment.