Skip to content

Commit

Permalink
Merge branch '5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Jul 30, 2019
2 parents 33c66a4 + e4b4d63 commit 3908e8b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"ext-zip": "*",
"facebook/webdriver": "^1.7",
"nesbot/carbon": "^1.20|^2.0",
"illuminate/console": "~5.7.0|~5.8.0|~5.9.0",
"illuminate/support": "~5.7.0|~5.8.0|~5.9.0",
"illuminate/console": "~5.7.0|~5.8.0|^6.0",
"illuminate/support": "~5.7.0|~5.8.0|^6.0",
"symfony/console": "^4.0",
"symfony/finder": "^4.0",
"symfony/process": "^4.0",
Expand Down
36 changes: 36 additions & 0 deletions src/Concerns/MakesAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,42 @@ public function assertDisabled($field)
return $this;
}

/**
* Assert that the given button is enabled.
*
* @param string $button
* @return $this
*/
public function assertButtonEnabled($button)
{
$element = $this->resolver->resolveForButtonPress($button);

PHPUnit::assertTrue(
$element->isEnabled(),
"Expected button [{$button}] to be enabled, but it wasn't."
);

return $this;
}

/**
* Assert that the given button is disabled.
*
* @param string $button
* @return $this
*/
public function assertButtonDisabled($button)
{
$element = $this->resolver->resolveForButtonPress($button);

PHPUnit::assertFalse(
$element->isEnabled(),
"Expected button [{$button}] to be disabled, but it wasn't."
);

return $this;
}

/**
* Assert that the given field is focused.
*
Expand Down
36 changes: 36 additions & 0 deletions tests/MakesAssertionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,42 @@ public function test_assert_disabled()
}
}

public function test_assert_button_enabled()
{
$this->expectException(ExpectationFailedException::class);
$this->expectExceptionMessage("Expected button [Cant press me] to be enabled, but it wasn't.");

$driver = m::mock(stdClass::class);
$resolver = m::mock(stdClass::class);
$resolver->shouldReceive('resolveForButtonPress->isEnabled')->andReturn(
true,
false
);
$browser = new Browser($driver, $resolver);

$browser->assertButtonEnabled('Press me');

$browser->assertButtonEnabled('Cant press me');
}

public function test_assert_button_disabled()
{
$this->expectException(ExpectationFailedException::class);
$this->expectExceptionMessage("Expected button [Press me] to be disabled, but it wasn't.");

$driver = m::mock(stdClass::class);
$resolver = m::mock(stdClass::class);
$resolver->shouldReceive('resolveForButtonPress->isEnabled')->twice()->andReturn(
false,
true
);
$browser = new Browser($driver, $resolver);

$browser->assertButtonDisabled('Cant press me');

$browser->assertButtonDisabled('Press me');
}

public function test_assert_focused()
{
$driver = m::mock(stdClass::class);
Expand Down

0 comments on commit 3908e8b

Please sign in to comment.