Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 13, 2021
1 parent 97cb71d commit 334c49f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
50 changes: 22 additions & 28 deletions src/Concerns/MakesAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,9 @@ public function assertValue($selector, $value)
{
$fullSelector = $this->resolver->format($selector);

$element = $this->resolver->findOrFail($selector);
$tagName = $element->getTagName();

PHPUnit::assertTrue(
$tagName === 'textarea' || $this->supportsTheValueAttribute($tagName),
__FUNCTION__." cannot be used with the element [{$fullSelector}]."
$this->ensureElementSupportsValueAttribute(
$element = $this->resolver->findOrFail($selector),
$fullSelector
);

$actual = $element->getAttribute('value');
Expand All @@ -679,12 +676,9 @@ public function assertValueIsNot($selector, $value)
{
$fullSelector = $this->resolver->format($selector);

$element = $this->resolver->findOrFail($selector);
$tagName = $element->getTagName();

PHPUnit::assertTrue(
$tagName === 'textarea' || $this->supportsTheValueAttribute($tagName),
__FUNCTION__." cannot be used with the element [{$fullSelector}]."
$this->ensureElementSupportsValueAttribute(
$element = $this->resolver->findOrFail($selector),
$fullSelector
);

$actual = $element->getAttribute('value');
Expand All @@ -699,25 +693,25 @@ public function assertValueIsNot($selector, $value)
}

/**
* Determine if the given element supports the 'value' attribute.
* Ensure the given element supports the 'value' attribute.
*
* @param string $tagName
* @return bool
* @param mixed $element
* @param string $fullSelector
* @return void
*/
public function supportsTheValueAttribute($tagName)
public function ensureElementSupportsValueAttribute($element, $fullSelector)
{
return in_array(
$tagName,
[
'button',
'input',
'li',
'meter',
'option',
'param',
'progress',
]
);
$tagName = $element->getTagName();

PHPUnit::assertTrue($tagName === 'textarea' || in_array($tagName, [
'button',
'input',
'li',
'meter',
'option',
'param',
'progress',
]), "This assertion cannot be used with the element [{$fullSelector}].");
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/MakesAssertionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public function test_assert_value_using_unsupported_element()
$browser->assertValue('foo', 'bar');
} catch (ExpectationFailedException $e) {
$this->assertStringContainsString(
'assertValue cannot be used with the element [body foo].',
'This assertion cannot be used with the element [body foo].',
$e->getMessage()
);
}
Expand All @@ -549,7 +549,7 @@ public function test_assert_value_is_not_using_unsupported_element()
$browser->assertValueIsNot('foo', 'foo');
} catch (ExpectationFailedException $e) {
$this->assertStringContainsString(
'assertValueIsNot cannot be used with the element [body foo].',
'This assertion cannot be used with the element [body foo].',
$e->getMessage()
);
}
Expand Down

0 comments on commit 334c49f

Please sign in to comment.