【发布时间】:2016-02-06 11:42:43
【问题描述】:
我正在尝试为应用程序编写一些测试。我在 MAMP 上设置了服务器,将访问 dev.myappnamehere.com。
当我运行测试时(基于 Laracasts Integrated)它失败了,因为它正在寻找路线
http://localhost/p/profile
但它需要去的是
http://dev.myappnamehere/p/profile
我怎样才能改变它,使它不默认寻找本地主机,而是转到正确的路径?
我试图在测试中更改这一点,但没有成功,我无法通过谷歌搜索找到答案。
<?php
use Laracasts\Integrated\Extensions\Laravel as IntegrationTest;
use Laracests\TestDummy\Factory as TestDummy;
class ExampleTest extends TestCase {
/**
* A basic functional test example.
*
* @return void
*/
public function testBasicExample()
{
$this->visit('/')
->see('Login')
->type('example@example.com', 'email')
->type('password', 'password')
->press('Login')
->seePageIs('/p/profile');
}
}
【问题讨论】:
-
发布你的phpunit测试代码?
-
您是否将
config/app.php中的config.url设置为http://dev.myappnamehere? -
其实我刚刚解决了。在 LaravelTestCase.php 中有一个 baseUrl,一旦我改变了测试在正确的位置查看
标签: php laravel testing phpunit integration-testing