Skip to content

Commit efa61e7

Browse files
committed
refactor: remove setChecked method and update tests to use check/uncheck directly
1 parent 6d59748 commit efa61e7

4 files changed

Lines changed: 4 additions & 43 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"rector --dry-run",
5959
"pint --test"
6060
],
61-
"test:unit": "pest --parallel --coverage --exactly=84.8",
61+
"test:unit": "pest --parallel --coverage --exactly=84.6",
6262
"test:types": "phpstan",
6363
"test": [
6464
"@test:lint",

src/Playwright/Element.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,6 @@ public function __construct(
2222
//
2323
}
2424

25-
/**
26-
* Check element.
27-
*/
28-
public function check(): void
29-
{
30-
$this->processVoidResponse($this->sendMessage('check'));
31-
}
32-
33-
/**
34-
* Uncheck element.
35-
*/
36-
public function uncheck(): void
37-
{
38-
$this->processVoidResponse($this->sendMessage('uncheck'));
39-
}
40-
4125
/**
4226
* Tap the element (touch screen interaction).
4327
*

src/Playwright/Locator.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -585,23 +585,6 @@ public function selectText(): void
585585
$element->selectText();
586586
}
587587

588-
/**
589-
* Set the checked state of a checkbox or radio.
590-
*/
591-
public function setChecked(bool $checked): void
592-
{
593-
$element = $this->elementHandle();
594-
if (! $element instanceof Element) {
595-
throw new RuntimeException('Element not found');
596-
}
597-
598-
if ($checked) {
599-
$element->check();
600-
} else {
601-
$element->uncheck();
602-
}
603-
}
604-
605588
/**
606589
* Take a screenshot of the element.
607590
*

tests/Browser/Playwright/Locator/InputMethodsTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
$page = page()->goto('/test/element-tests');
1818
$checkbox = $page->getByTestId('checkbox-input');
1919

20-
$checkbox->setChecked(true);
20+
$checkbox->check();
2121
expect($checkbox->isChecked())->toBeTrue();
2222

23-
$checkbox->setChecked(false);
23+
$checkbox->uncheck();
2424
expect($checkbox->isChecked())->toBeFalse();
2525

26-
$checkbox->setChecked(true);
26+
$checkbox->check();
2727
expect($checkbox->isChecked())->toBeTrue();
2828
});
2929

@@ -35,10 +35,4 @@
3535
->toThrow(RuntimeException::class, 'Element not found');
3636
});
3737

38-
it('throws RuntimeException when setChecked element is not found', function (): void {
39-
$page = page()->goto('/test/element-tests');
40-
$locator = $page->locator('.non-existent-element');
4138

42-
expect(fn () => $locator->setChecked(true))
43-
->toThrow(RuntimeException::class, 'Element not found');
44-
});

0 commit comments

Comments
 (0)