Skip to content

Commit

Permalink
kill mutants
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Oct 3, 2024
1 parent 56d1d69 commit 0cca3b9
Showing 1 changed file with 136 additions and 0 deletions.
136 changes: 136 additions & 0 deletions tests/Field/CheckboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,142 @@ public function testLabelPlacement(string $expected, CheckboxLabelPlacement $pla
$this->assertSame($expected, $result);
}

public static function dataLabelPlacementWithInputLabel(): iterable
{
yield 'default' => [
<<<HTML
<div>
<label for="UID">Voronezh</label>
<input type="checkbox" id="UID" name="city" value="1"> Moscow
</div>
HTML,
CheckboxLabelPlacement::DEFAULT,
];
yield 'wrap' => [
<<<HTML
<div>
<label><input type="checkbox" id="UID" name="city" value="1"> Moscow</label>
</div>
HTML,
CheckboxLabelPlacement::WRAP,
];
yield 'side' => [
<<<HTML
<div>
<input type="checkbox" id="UID" name="city" value="1"> <label for="UID">Moscow</label>
</div>
HTML,
CheckboxLabelPlacement::SIDE,
];
}

#[DataProvider('dataLabelPlacementWithInputLabel')]
public function testLabelPlacementWithInputLabel(string $expected, CheckboxLabelPlacement $placement): void
{
$inputData = new InputData('city', label: 'Voronezh');

$result = Checkbox::widget()
->inputData($inputData)
->inputLabel('Moscow')
->inputId('UID')
->uncheckValue(null)
->labelPlacement($placement)
->render();

$this->assertSame($expected, $result);
}

public static function dataLabelPlacementWithLabel(): iterable
{
yield 'default' => [
<<<HTML
<div>
<label for="UID">Moscow</label>
<input type="checkbox" id="UID" name="city" value="1">
</div>
HTML,
CheckboxLabelPlacement::DEFAULT,
];
yield 'wrap' => [
<<<HTML
<div>
<label><input type="checkbox" id="UID" name="city" value="1"> Moscow</label>
</div>
HTML,
CheckboxLabelPlacement::WRAP,
];
yield 'side' => [
<<<HTML
<div>
<input type="checkbox" id="UID" name="city" value="1"> <label for="UID">Moscow</label>
</div>
HTML,
CheckboxLabelPlacement::SIDE,
];
}

#[DataProvider('dataLabelPlacementWithLabel')]
public function testLabelPlacementWithLabel(string $expected, CheckboxLabelPlacement $placement): void
{
$inputData = new InputData('city', label: 'Voronezh');

$result = Checkbox::widget()
->inputData($inputData)
->label('Moscow')
->inputId('UID')
->uncheckValue(null)
->labelPlacement($placement)
->render();

$this->assertSame($expected, $result);
}

public static function dataLabelPlacementWithLabelAndInputLabel(): iterable
{
yield 'default' => [
<<<HTML
<div>
<label for="UID">Vladivostok</label>
<input type="checkbox" id="UID" name="city" value="1"> Moscow
</div>
HTML,
CheckboxLabelPlacement::DEFAULT,
];
yield 'wrap' => [
<<<HTML
<div>
<label><input type="checkbox" id="UID" name="city" value="1"> Moscow</label>
</div>
HTML,
CheckboxLabelPlacement::WRAP,
];
yield 'side' => [
<<<HTML
<div>
<input type="checkbox" id="UID" name="city" value="1"> <label for="UID">Moscow</label>
</div>
HTML,
CheckboxLabelPlacement::SIDE,
];
}

#[DataProvider('dataLabelPlacementWithLabelAndInputLabel')]
public function testLabelPlacementWithLabelAndInputLabel(string $expected, CheckboxLabelPlacement $placement): void
{
$inputData = new InputData('city', label: 'Voronezh');

$result = Checkbox::widget()
->inputData($inputData)
->inputLabel('Moscow')
->label('Vladivostok')
->inputId('UID')
->uncheckValue(null)
->labelPlacement($placement)
->render();

$this->assertSame($expected, $result);
}

public function testImmutability(): void
{
$widget = Checkbox::widget();
Expand Down

0 comments on commit 0cca3b9

Please sign in to comment.