Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Oct 26, 2022
1 parent bb54372 commit 96be016
Showing 1 changed file with 46 additions and 66 deletions.
112 changes: 46 additions & 66 deletions tests/FormElement/RadioElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ public function testCreateRadioElementsCorrectly()
]
]);

$this->assertHtml(
<<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio">Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio">Yes</label>
HTML
,
$radio
);
$html = <<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio">Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio">Yes</label>
HTML;

$this->assertHtml($html, $radio);
}

public function testCheckCorrectRadio()
Expand All @@ -43,39 +41,30 @@ public function testCheckCorrectRadio()
'value' => 'bar'
]);

$this->assertHtml(
<<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio" checked>Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio">Yes</label>
HTML
,
$radio
);
$html = <<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio" checked>Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio">Yes</label>
HTML;
$this->assertHtml($html, $radio);

$radio->setValue('yes');

$this->assertHtml(
<<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio">Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio" checked>Yes</label>
HTML
,
$radio
);
$html = <<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio">Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio" checked>Yes</label>
HTML;
$this->assertHtml($html, $radio);

$radio->setValue('no');

$this->assertHtml(
<<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio">Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio">Yes</label>
HTML
,
$radio
);
$html = <<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio">Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio">Yes</label>
HTML;
$this->assertHtml($html, $radio);
}

public function testDisableRadioOptions()
Expand All @@ -92,42 +81,33 @@ public function testDisableRadioOptions()
'disableOptions' => 'yes'
]);

$this->assertHtml(
<<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio" checked>Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio" disabled>Yes</label>
<label class="radio-label"><input value="no" name="test" type="radio">No</label>
HTML
,
$radio
);
$html = <<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio">Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio" checked>Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio" disabled>Yes</label>
<label class="radio-label"><input value="no" name="test" type="radio">No</label>
HTML;
$this->assertHtml($html, $radio);

$radio->disableOptions(['yes', 'no', 'foo']);

$this->assertHtml(
<<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio" disabled>Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio" checked>Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio" disabled>Yes</label>
<label class="radio-label"><input value="no" name="test" type="radio" disabled>No</label>
HTML
,
$radio
);
$html = <<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio" disabled>Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio" checked>Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio" disabled>Yes</label>
<label class="radio-label"><input value="no" name="test" type="radio" disabled>No</label>
HTML;
$this->assertHtml($html, $radio);

$radio->disableOptions(true);

$this->assertHtml(
<<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio" disabled>Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio" checked disabled>Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio" disabled>Yes</label>
<label class="radio-label"><input value="no" name="test" type="radio" disabled>No</label>
HTML
,
$radio
);
$html = <<<HTML
<label class="radio-label"><input value="foo" name="test" type="radio" disabled>Foo</label>
<label class="radio-label"><input value="bar" name="test" type="radio" checked disabled>Bar</label>
<label class="radio-label"><input value="yes" name="test" type="radio" disabled>Yes</label>
<label class="radio-label"><input value="no" name="test" type="radio" disabled>No</label>
HTML;
$this->assertHtml($html, $radio);
}

public function testRadioNotValidIfCheckedValueIsInvalid()
Expand Down

0 comments on commit 96be016

Please sign in to comment.