我需要在 Laravel 中使用单元测试,但需要下载库 laravel/browser-kit-testing
。当我下载它时,它告诉我需要 PHP 5.6,而我正在使用 PHP 5.4。
public function testBasicTest()
{
$this->visit('/home')
->seePageIs('/login');
$response = $this->call('GET', '/dradmin');
$this->assertEquals(200, $response->status());
$this->visit('/login')
->type('mahmoud@mahmoud.com', 'email')
->type('123456', 'password')
->press('Login')
->seePageIs('/home');
}
}
当使用 phpunit
时
Error: Call to undefined method Tests\Feature\UserTest::visit()
/Users/mahmoud310/ecare/tests/Feature/UserTest.php:21
我在其他问题中看到了这个内容:Laravel 5.4 HTTP测试 - 方法seeInElement
使用命令 laravel/browser-kit-testing
可以解决问题。
但在我的情况下没有起作用。
Using version ^1.0 for laravel/browser-kit-testing
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package phpunit/phpunit (locked at 5.7.19, required as 4.8.*) is satisfiable by phpunit/phpunit[5.7.19] but these conflict with your requirements or minimum-stability.
Problem 2
- Conclusion: don't install phpunit/phpunit 4.8.35
...
- Conclusion: don't install phpunit/phpunit 4.8.1
- phpunit/phpunit 4.8.0 conflicts with phpunit/phpunit-mock-objects[3.4.3].
...
- phpunit/phpunit 4.8.0 conflicts with phpunit/phpunit-mock-objects[3.4.3].
- Installation request for phpunit/phpunit 4.8.* -> satisfiable by phpunit/phpunit[4.8.0, 4.8.1, ..., 4.8.9].
- Installation request for phpunit/phpunit-mock-objects (locked at 3.4.3) -> satisfiable by phpunit/phpunit-mock-objects[3.4.3].
Installation failed, reverting ./composer.json to its original content.
./vendor/phpunit/phpunit/phpunit
。 - Little Phildcomposer install
命令来安装 Laravel 依赖吗? - Little Phild