GithubHelp home page GithubHelp logo

Comments (10)

kamui545 avatar kamui545 commented on July 28, 2024 8

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.

phpguru avatar phpguru commented on July 28, 2024 4

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.

kamui545 avatar kamui545 commented on July 28, 2024 2

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.

redgluten avatar redgluten commented on July 28, 2024 2

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.

tms320c avatar tms320c commented on July 28, 2024 1

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.

hohl avatar hohl commented on July 28, 2024

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.

valorin avatar valorin commented on July 28, 2024

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.

redgluten avatar redgluten commented on July 28, 2024

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.

ajcastro avatar ajcastro commented on July 28, 2024

What is the recommended browserkit and phpunit to use?

from browser-kit-testing.

driesvints avatar driesvints commented on July 28, 2024

Library now requires a minimum of PHPUnit 7.0

from browser-kit-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.