-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove parsing, selector logic from the trait; introduce custom constraints #46
Open
stevegrunwell
wants to merge
13
commits into
develop
Choose a base branch
from
refactor/remove-logic-from-trait
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
stevegrunwell
changed the title
Refactor/remove logic from trait
Remove parsing, selector logic from the trait; introduce custom constraints
Dec 11, 2023
…it tests (individual classes)
… methods from the trait
stevegrunwell
force-pushed
the
refactor/remove-logic-from-trait
branch
from
December 12, 2023 01:08
d0b13e8
to
705a1a6
Compare
stevegrunwell
force-pushed
the
refactor/remove-logic-from-trait
branch
from
December 12, 2023 01:19
705a1a6
to
8dbabbc
Compare
stevegrunwell
force-pushed
the
refactor/remove-logic-from-trait
branch
2 times, most recently
from
December 12, 2023 01:53
d0dfc60
to
895c8d0
Compare
stevegrunwell
force-pushed
the
refactor/remove-logic-from-trait
branch
2 times, most recently
from
December 12, 2023 03:11
0d6a9cd
to
f85fca4
Compare
…r handling differences in exporting values
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In preparation for version 2.x of this library, this PR introduces a series of custom PHPUnit constraints (based on
PHPUnit\Framework\Constraint\Constraint
), enabling greater flexibility with regards to how assertions are handled.For example,
assertContainsSelector()
currently relies on counting the number of matches:When the assertion fails, users see a message like "Failed asserting that 0 is greater than 0", which isn't particularly helpful.
With the new version, we can get messages like this:
The new constraints also make code much easier to test and re-use across assertions.
The Selector class
Rather than having a series of internal methods end up exposed on implementing test classes, this PR uses a new
Selector
class, which acts as a value object for CSS selectors. If given an array of attributes, this is automatically converted into the appropriate CSS selector.The DOM class
This PR also defines the
DOM
class, which is a simple wrapper around Symfony'sCrawler
class that exposes the methods necessary to query usingSelector
objects.Backwards compatibility
In order to be compatible with current versions of PHPUnit, this PR does raise the minimum PHP version to 7.0. While I want to keep support as broad as possible (after all, this originally started because I had to try to write some regression tests around WordPress), the fact that version 1.x is still available for those poor, unlucky souls means they aren't totally left out in the cold.