【发布时间】:2017-10-02 09:18:41
【问题描述】:
我需要在 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 testing - method 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 -
不行!显示相同的错误
-
你有没有
composer install安装 laravel 依赖项 -
是的,作曲家更新最后一次更改
-
我建议如果您不使用宅基地,您可以使用本指南进行设置 Installing HomeStead
标签: unit-testing laravel-5 phpunit composer-php laravel-5.4