dimanche 3 janvier 2016

Calling named routes in laravel tests

consider the following:

<?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());
    }
}

Is there away, not that I have seen documented >.>, to do something like:

$response = $this->call('GET', 'home.about');
$this->assertEquals(200, $response->status());

Or .... Is that how you do it?

The error I get is:

vagrant@scotchbox:/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.

Aucun commentaire:

Enregistrer un commentaire