- What is phpunit/phpunit-dom-assertions used for?
- It is a test-only Composer dev dependency that acts as a work-in-progress drop-in replacement for PHPUnit's deprecated DOM assertions. It adds readable checks for elements, attributes, text, and selectors in rendered markup. Laravel teams use it to make view, component, and HTML/XML response tests clearer and easier to maintain.
- How do I install phpunit/phpunit-dom-assertions as a dev dependency?
- Install it with Composer under require-dev, for example composer require --dev phpunit/phpunit-dom-assertions. Pin an exact version in composer.json and commit the lockfile because the package is work in progress. Confirm PHPUnit and PHP compatibility plus license terms before rolling it out.
- Can I use phpunit/phpunit-dom-assertions with Pest in a Laravel project?
- It is intended for Laravel projects using PHPUnit or Pest because Pest runs on PHPUnit underneath. Pest plugin compatibility and custom test base classes should be validated on a branch before adoption. Run a representative Pest suite to confirm assertion parity.
- Which Laravel versions does phpunit/phpunit-dom-assertions support?
- The provided context does not list an explicit Laravel version matrix. Because it is a test-only PHPUnit helper, support mainly depends on your PHP, PHPUnit or Pest, and Laravel test setup. Validate it against your current Laravel and CI matrix before upgrading.
- Which PHPUnit versions are compatible with phpunit/phpunit-dom-assertions?
- The context does not specify a PHPUnit compatibility matrix. The package targets PHPUnit's deprecated DOM assertion behavior, so PHPUnit major-version boundaries are the main risk. Check the package documentation and run a pilot before replacing existing assertions.
- Is phpunit/phpunit-dom-assertions safe to use in production?
- No, it is a test-only Composer dev dependency and should not be used as a runtime production component. It does not change Laravel service providers, middleware, or deployment architecture. Keep it in require-dev and out of production dependencies.
- How do I migrate a Laravel test suite from PHPUnit's deprecated DOM assertions?
- Inventory existing assert DOM and XML usages first, then pin the package to an exact version on a short-lived branch. Replace deprecated assertions incrementally by test area and compare results against the current suite. Keep a rollback path to native PHPUnit assertions or local helpers until parity is proven.
- Does phpunit/phpunit-dom-assertions need a service provider or test bootstrap change?
- It is not described as a Laravel service provider; integration is expected in the PHPUnit test layer. The context does not confirm whether it works automatically or requires a trait, bootstrap change, or namespace alias. Review the package docs and pilot it on one suite before broad adoption.
- What are alternatives to phpunit/phpunit-dom-assertions?
- You can keep native PHPUnit DOM assertions where available or create project-owned helper methods for HTML and DOM checks. If the package fails license or support requirements, vendor a reviewed copy or replace assertions with internal helpers. The best alternative depends on your PHPUnit version and migration timeline.
- What maintenance and license risks should I check before adopting phpunit/phpunit-dom-assertions?
- The package is explicitly work in progress, has weak repository visibility, and reports a NOASSERTION license, so due diligence is required. Confirm the public repository, issue tracker, CI evidence, release cadence, PHPUnit support, and actual license terms. Assign an internal owner and be prepared to patch or fork if upstream maintenance stops.