Comments (10)
It's simple.
If you are using PHPUnit 5.x, use browser-kit-testing 1.x
If you are using PHPunit 6.x, use browser-kit-testing 2.x
from browser-kit-testing.
For Laravel 5.4, I found that my global PHPUnit > 6 was too new, and just running $ phpunit path/to/test.php
was breaking with this error. I had "phpunit/phpunit": "^6.0.3",
in composer.json. After reading this and other similar issues around the web, the problem went away after downgrading PHPUnit by using "phpunit/phpunit": "~5.7",
in composer.json, running composer update
, and then using the project-specific PHPUnit to run tests $ vendor/bin/phpunit path/to/test.php
.
from browser-kit-testing.
For some reasons it looks like adding those aliases in config/app.php
does not work (at least on my setup)
What I did is adding in tests/BrowserKitTestCase.php
the following code (you may need to add more aliases, depending on your tests):
class_alias(\PHPUnit\Framework\TestCase::class, 'PHPUnit_Framework_TestCase');
class_alias(\PHPUnit\Framework\Assert::class, 'PHPUnit_Framework_Assert');
class_alias(\PHPUnit\Framework\Constraint\Constraint::class, 'PHPUnit_Framework_Constraint');
from browser-kit-testing.
Ah you’re right, so there’s an issue with the upgrade guide with the command for requiring browser-kit-testing
: composer require laravel/browser-kit-testing --dev
gets 2.0 despite the guide recommending to use phpunit ~5.7. I’ll submit a PR.
from browser-kit-testing.
I use PHPUnit 5.7 and I got laravel/browser-kit-testing version 2.0.0, which does not work with PHPUnit 5
Thanks to @kamui545 it can be fixed in the same but mirrored way: add to tests/BrowserKitTestCase.php the following code:
class_alias('PHPUnit_Framework_TestCase', \PHPUnit\Framework\TestCase::class);
class_alias( 'PHPUnit_Framework_Assert',\PHPUnit\Framework\Assert::class);
class_alias('PHPUnit_Framework_Constraint', \PHPUnit\Framework\Constraint\Constraint::class);
from browser-kit-testing.
Any ideas why it fails? Would it be hard to fix that and support PHPUnit 6 too? Is it just PHPUnit\Framework\TestCase
or would there something else need to change?
from browser-kit-testing.
A really sneaky cheat for this is to add this into your app.aliases
config list:
'PHPUnit_Framework_Assert' => \PHPUnit\Framework\Assert::class,
from browser-kit-testing.
Same situation as @tms320c : laravel 5.4.27, browser-kit-testing 2.0.0 and phpunit 5.7.20. I followed the Upgrade guide instructions to keep my existing tests and I got a Fatal error: Class 'PHPUnit\Framework\Constraint\Constraint' not found
. Using the class aliases fixed the problem.
Should we open another ticket?
from browser-kit-testing.
What is the recommended browserkit and phpunit to use?
from browser-kit-testing.
Library now requires a minimum of PHPUnit 7.0
from browser-kit-testing.
Related Issues (20)
- 无法调用ChoiceFormField类的disableValidation方法 HOT 1
- Dependency Issue on Laravel 6.9.x HOT 6
- Does browser-kit run with the latest Spark install? HOT 1
- [SOLVED] Call to a member function selectLink() on null HOT 2
- Use of assertIsArray in seeJsonStructure requires phpunit >= 7.5 HOT 2
- Use illuminate/testing HOT 1
- Add support for phpunit 9.x to v5.x HOT 1
- Extending from Laravel\BrowserKitTesting\TestCase lose assertions that I already know/have HOT 1
- Multiple Forms with same name tag HOT 1
- Set cookies on requests HOT 2
- Outdated MocksApplicationServices.php implementation HOT 1
- Outdated MocksApplicationServices.php implementation HOT 8
- Add documentation about Laravel versions compatibility HOT 5
- MakesHttpRequest wrong return-value in phpdoc block HOT 1
- External URL testing purpose HOT 2
- Support for parallel testing HOT 2
- Assert response is json broken in v6 HOT 5
- Support for phpunit10 HOT 1
- ADD Null Safety HOT 2
- Sail and parallel testing HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browser-kit-testing.