Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

also test labels

  • Loading branch information...
commit 39bdec7946ecc485d7f37afb93759e2dc540c11a 1 parent 8a775f1
@scribu authored
Showing with 20 additions and 10 deletions.
  1. +1 −1  scb
  2. +19 −9 tests/test-forms.php
2  scb
@@ -1 +1 @@
-Subproject commit c5237ca2a48b9135c9e0b86052696aed7e7c55da
+Subproject commit 5113202960a29ef7a8ee2100763eff9f4807a22c
View
28 tests/test-forms.php
@@ -36,19 +36,23 @@ function testRadio() {
$fd = self::domify( scbForms::input( array(
'name' => __FUNCTION__,
'type' => 'radio',
- 'choices' => $choices
+ 'choices' => $choices,
) ) );
- $radios = $fd->find('//input[@type="radio"]');
+ $labels = $fd->find('//label');
- $this->assertCount( count( $choices ), $radios );
+ $this->assertCount( count( $choices ), $labels );
- foreach ( $radios as $i => $radio ) {
- $el = FluentDOM( $radio );
+ foreach ( $labels as $i => $label ) {
+ $label = FluentDOM( $label );
+
+ $el = $label->find('.//input[@type="radio"]');
$this->assertEquals( __FUNCTION__, $el->attr('name') );
$this->assertEquals( $choices[ $i ], $el->attr('value') );
+
+ $this->assertEquals( ' ' . $choices[ $i ], $label->text() );
}
}
@@ -61,16 +65,20 @@ function testCheckbox() {
'choices' => $choices
) ) );
- $checkboxes = $fd->find('//input[@type="checkbox"]');
+ $labels = $fd->find('//label');
- $this->assertCount( count( $choices ), $checkboxes );
+ $this->assertCount( count( $choices ), $labels );
- foreach ( $checkboxes as $i => $radio ) {
- $el = FluentDOM( $radio );
+ foreach ( $labels as $i => $label ) {
+ $label = FluentDOM( $label );
+
+ $el = $label->find('.//input[@type="checkbox"]');
$this->assertEquals( 'maxi[pads][]', $el->attr('name') );
$this->assertEquals( $choices[ $i ], $el->attr('value') );
+
+ $this->assertEquals( ' ' . $choices[ $i ], $label->text() );
}
}
@@ -99,6 +107,8 @@ function testSelect() {
$el = FluentDOM( $option );
$this->assertEquals( $choices[ $i ], $el->attr('value') );
+
+ $this->assertEquals( $choices[ $i ], $el->text() );
}
$fd = self::domify( scbForms::input( array_merge( $args, array( 'selected' => '1 1/3' ) ) ) );
Please sign in to comment.
Something went wrong with that request. Please try again.