-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add forgotten getter method to get the DOM query that is attached to an `InvalidDomQueryException` instance.
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/Steps/Html/Exceptions/InvalidDomQueryExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace tests\Steps\Html\Exceptions; | ||
|
||
use Crwlr\Crawler\Steps\Html\Exceptions\InvalidDomQueryException; | ||
use Symfony\Component\CssSelector\Exception\ExpressionErrorException; | ||
use Symfony\Component\CssSelector\Exception\SyntaxErrorException; | ||
|
||
it('can be created from a symfony ExpressionErrorException', function () { | ||
$exception = InvalidDomQueryException::fromSymfonyException('.foo:before', new ExpressionErrorException('error')); | ||
|
||
expect($exception->getDomQuery()) | ||
->toBe('.foo:before') | ||
->and($exception->getMessage()) | ||
->toBe('error'); | ||
}); | ||
|
||
it('can be created from a symfony SyntaxErrorException', function () { | ||
$exception = InvalidDomQueryException::fromSymfonyException('.foo;', new SyntaxErrorException('error message')); | ||
|
||
expect($exception->getDomQuery()) | ||
->toBe('.foo;') | ||
->and($exception->getMessage()) | ||
->toBe('error message'); | ||
}); | ||
|
||
it('can be created from a message and a query', function () { | ||
$exception = InvalidDomQueryException::make('message', '.foo > .bar;'); | ||
|
||
expect($exception->getDomQuery()) | ||
->toBe('.foo > .bar;') | ||
->and($exception->getMessage()) | ||
->toBe('message'); | ||
}); |