Remove parsing, selector logic from the trait; introduce custom constraints - #46
Open
stevegrunwell wants to merge 13 commits into
Open
Remove parsing, selector logic from the trait; introduce custom constraints#46stevegrunwell wants to merge 13 commits into
stevegrunwell wants to merge 13 commits into
Conversation
…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
This file contains hidden or 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
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
Selectorclass, 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
DOMclass, which is a simple wrapper around Symfony'sCrawlerclass that exposes the methods necessary to query usingSelectorobjects.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.