考慮以下幾點:在laravel調用命名路由測試
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class HomeRouteTest extends TestCase
{
public function testVisitTheHomePage()
{
$response = $this->call('GET', '/');
$this->assertEquals(200, $response->status());
}
public function testVisitTheAboutPage()
{
$response = $this->call('GET', '/about');
$this->assertEquals(200, $response->status());
}
}
有沒有去,不是我所看到的記錄>>,做這樣的事情:
$response = $this->call('GET', 'home.about');
$this->assertEquals(200, $response->status());
或...這是你如何做到的?
我得到的錯誤是:
[email protected]:/var/www$ phpunit
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
FF
Time: 3.41 seconds, Memory: 14.25Mb
There were 2 failures:
1) HomeRouteTest::testVisitTheHomePage
Failed asserting that 404 matches expected 200.
/var/www/tests/HomeRouteTest.php:12
2) HomeRouteTest::testVisitTheAboutPage
Failed asserting that 404 matches expected 200.
/var/www/tests/HomeRouteTest.php:19
FAILURES!
Tests: 2, Assertions: 2, Failures: 2.
這不再適用於Laravel 5.4 - 調用未定義的方法route() – Julian