Fulguletz's avatar

PHPUnit with default test fails

The default unit test public function testBasicExample() { $this->visit('/') ->see('Laravel'); } tries to use a method that does not exist anymore. The class that used to have it: vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php is not in the repo anymore

Laravel 5.3 had:

  • ImpersonatesUsers.php
  • InteractsWithConsole.php
  • InteractsWithDatabase.php
  • InteractsWithSession.php
  • MocksApplicationServices.php
  • InteractsWithAuthentication.php
  • InteractsWithContainer.php
  • InteractsWithPages.php
  • MakesHttpRequests.php

But now in Laravel 5.4 only have:

  • InteractsWithAuthentication.php
  • InteractsWithConsole.php
  • InteractsWithContainer.php
  • InteractsWithDatabase.php
  • InteractsWithSession.php
  • MakesHttpRequests.php
  • MocksApplicationServices.php

The error is:

PHPUnit 5.7.8 by Sebastian Bergmann and contributors.

E 1 / 1 (100%)

Time: 49 ms, Memory: 8.00MB

There was 1 error:

  1. ExampleTest::testBasicExample Error: Call to undefined method ExampleTest::visit()

/var/www/webapp/tests/ExampleTest.php:16 /root/.config/composer/vendor/phpunit/phpunit/src/TextUI/Command.php:188 /root/.config/composer/vendor/phpunit/phpunit/src/TextUI/Command.php:118

ERRORS! Tests: 1, Assertions: 0, Errors: 1.

Is this an intended change, and we should change all our unit tests, or a bug? Thanks

0 likes
1 reply
Fulguletz's avatar

Nvm it seems this only happends if you first install laravel 5.3 and then upgrade to laravel 5.4 and you don't include the old libraries from laravel/browser-kit-testing.

Please or to participate in this conversation.