In Laravel specifically you can use the classes of the Illuminate\Foundation\Testing\
namespace (source: link )
Note that the example here is for Laravel5.2
Within the tests
folder within your application Laravel should contain two files, the TestCase.php
which is the "base" for creating your tests and the ExampleTest.php
that you can use to create your tests or then you can create a new file, all files you create must end with Test.php
, for example:
-
FooTest.php
-
BarTest.php
-
BazTest.php
An example:
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ExampleTest extends TestCase
{
public function testBasicExample()
{
$this->visit('/')
->see('Laravel 5')
->dontSee('Teste');
}
}
- The
visit
method makes a GET request in the application.
- The
see
method states that we should see in the application response the text Laravel 5
- The
dontSee
method says that we should not see response Teste
text in the application response
To get all the routes you can use the method ->getRoutes();
of class \Illuminate\Routing\Router
that will return an object of type:
20.04.2016 / 22:59