Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
feat: rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Apr 5, 2023
1 parent 607762a commit 8d380c5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
28 changes: 14 additions & 14 deletions src/HtmlAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,63 +21,63 @@
*/
trait HtmlAssertions
{
final public function see(string $expected): static
final public function contains(string $expected): static
{
$this->webAssert()->pageTextContains($expected);

return $this;
}

final public function notSee(string $expected): static
final public function doesNotContain(string $expected): static
{
$this->webAssert()->pageTextNotContains($expected);

return $this;
}

final public function seeIn(string $selector, string $expected): static
final public function containsIn(string $selector, string $expected): static
{
$this->webAssert()->elementTextContains('css', $selector, $expected);

return $this;
}

final public function notSeeIn(string $selector, string $expected): static
final public function doesNotContainIn(string $selector, string $expected): static
{
$this->webAssert()->elementTextNotContains('css', $selector, $expected);

return $this;
}

final public function seeElement(string $selector): static
final public function hasElement(string $selector): static
{
$this->webAssert()->elementExists('css', $selector);

return $this;
}

final public function notSeeElement(string $selector): static
final public function doesNotHaveElement(string $selector): static
{
$this->webAssert()->elementNotExists('css', $selector);

return $this;
}

final public function elementCount(string $selector, int $count): static
final public function hasElementCount(string $selector, int $count): static
{
$this->webAssert()->elementsCount('css', $selector, $count);

return $this;
}

final public function elementAttributeContains(string $selector, string $attribute, string $expected): static
final public function attributeContains(string $selector, string $attribute, string $expected): static
{
$this->webAssert()->elementAttributeContains('css', $selector, $attribute, $expected);

return $this;
}

final public function elementAttributeNotContains(string $selector, string $attribute, string $expected): static
final public function attributeDoesNotContain(string $selector, string $attribute, string $expected): static
{
$this->webAssert()->elementAttributeNotContains('css', $selector, $attribute, $expected);

Expand All @@ -91,14 +91,14 @@ final public function fieldEquals(string $selector, string $expected): static
return $this;
}

final public function fieldNotEquals(string $selector, string $expected): static
final public function fieldDoesNotEqual(string $selector, string $expected): static
{
$this->webAssert()->fieldValueNotEquals($selector, $expected);

return $this;
}

final public function selected(string $selector, string $expected): static
final public function fieldSelected(string $selector, string $expected): static
{
$field = $this->webAssert()->fieldExists($selector);

Expand All @@ -107,7 +107,7 @@ final public function selected(string $selector, string $expected): static
return $this;
}

final public function notSelected(string $selector, string $expected): static
final public function fieldNotSelected(string $selector, string $expected): static
{
$field = $this->webAssert()->fieldExists($selector);

Expand All @@ -116,14 +116,14 @@ final public function notSelected(string $selector, string $expected): static
return $this;
}

final public function checked(string $selector): static
final public function fieldChecked(string $selector): static
{
$this->webAssert()->checkboxChecked($selector);

return $this;
}

final public function notChecked(string $selector): static
final public function fieldNotChecked(string $selector): static
{
$this->webAssert()->checkboxNotChecked($selector);

Expand Down
88 changes: 44 additions & 44 deletions tests/HtmlExpectationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,56 +27,56 @@ final class HtmlExpectationTest extends TestCase
public function assertions(): void
{
(new HtmlExpectation(\file_get_contents(__DIR__.'/Fixtures/test.html')))
->see('h1 title')
->notSee('invalid text')
->seeIn('h1', 'title')
->notSeeIn('h1', 'invalid text')
->seeElement('h1')
->notSeeElement('h2')
->elementCount('ul li', 2)
->contains('h1 title')
->doesNotContain('invalid text')
->containsIn('h1', 'title')
->doesNotContainIn('h1', 'invalid text')
->hasElement('h1')
->doesNotHaveElement('h2')
->hasElementCount('ul li', 2)

// head assertions
->seeIn('title', 'meta title')
->elementAttributeContains('meta[name="description"]', 'content', 'meta')
->elementAttributeNotContains('meta[name="description"]', 'content', 'invalid')
->elementAttributeContains('html', 'lang', 'en')
->containsIn('title', 'meta title')
->attributeContains('meta[name="description"]', 'content', 'meta')
->attributeDoesNotContain('meta[name="description"]', 'content', 'invalid')
->attributeContains('html', 'lang', 'en')

// form assertions
->FieldEquals('Input 1', 'input 1')
->FieldEquals('input1', 'input 1')
->FieldEquals('input_1', 'input 1')
->FieldNotEquals('Input 1', 'invalid')
->FieldNotEquals('input1', 'invalid')
->FieldNotEquals('input_1', 'invalid')
->Checked('Input 3')
->Checked('input3')
->Checked('input_3')
->NotChecked('Input 2')
->NotChecked('input2')
->NotChecked('input_2')
->selected('Input 4', 'option 1')
->selected('input4', 'option 1')
->selected('input_4', 'option 1')
->selected('Input 7', 'option 1')
->selected('input7', 'option 1')
->selected('input_7[]', 'option 1')
->selected('Input 7', 'option 3')
->selected('input7', 'option 3')
->selected('input_7[]', 'option 3')
->notSelected('Input 4', 'option 2')
->notSelected('input4', 'option 2')
->notSelected('input_4', 'option 2')
->notSelected('Input 7', 'option 2')
->notSelected('input7', 'option 2')
->notSelected('input_7[]', 'option 2')
->notSelected('input_8', 'option 1')
->selected('input_8', 'option 2')
->notChecked('Radio 1')
->notChecked('radio1')
->notChecked('Radio 3')
->notChecked('radio3')
->checked('Radio 2')
->checked('radio2')
->fieldDoesNotEqual('Input 1', 'invalid')
->fieldDoesNotEqual('input1', 'invalid')
->fieldDoesNotEqual('input_1', 'invalid')
->fieldChecked('Input 3')
->fieldChecked('input3')
->fieldChecked('input_3')
->fieldNotChecked('Input 2')
->fieldNotChecked('input2')
->fieldNotChecked('input_2')
->fieldSelected('Input 4', 'option 1')
->fieldSelected('input4', 'option 1')
->fieldSelected('input_4', 'option 1')
->fieldSelected('Input 7', 'option 1')
->fieldSelected('input7', 'option 1')
->fieldSelected('input_7[]', 'option 1')
->fieldSelected('Input 7', 'option 3')
->fieldSelected('input7', 'option 3')
->fieldSelected('input_7[]', 'option 3')
->fieldNotSelected('Input 4', 'option 2')
->fieldNotSelected('input4', 'option 2')
->fieldNotSelected('input_4', 'option 2')
->fieldNotSelected('Input 7', 'option 2')
->fieldNotSelected('input7', 'option 2')
->fieldNotSelected('input_7[]', 'option 2')
->fieldNotSelected('input_8', 'option 1')
->fieldSelected('input_8', 'option 2')
->fieldNotChecked('Radio 1')
->fieldNotChecked('radio1')
->fieldNotChecked('Radio 3')
->fieldNotChecked('radio3')
->fieldChecked('Radio 2')
->fieldChecked('radio2')
;
}

Expand All @@ -87,7 +87,7 @@ public function failed_assertion(): void
{
$expectation = new HtmlExpectation(\file_get_contents(__DIR__.'/Fixtures/test.html'));

Assert::that(fn() => $expectation->seeIn('h1', 'invalid'))
Assert::that(fn() => $expectation->containsIn('h1', 'invalid'))
->throws(AssertionFailedError::class)
;
}
Expand Down

0 comments on commit 8d380c5

Please sign in to comment.