My test method has:
$this->visitRoute('route.name')->see('something');
Response:
There was 1 failure:
1) Tests\Unit\MyTest::testRoute
A request to [http://localhost/route.name] failed. Received status code [500].
Caused by
PDOException: SQLSTATE[HY000]: General error: 1 no such table 'tableThatExists'
BUT when I test:
$this->visit('/')
As provided in Laravel documentation, it works, what is wrong??
And also if I just want to test responses without "see" condition how do I do it?
If anybody knows simple basic laravel unit tests it could help as well
use Illuminate\Foundation\Testing\DatabaseMigrations;
in file and
use DatabaseMigrations;
in class
This error is because the app test is not finding the database.
Try with:
Into phpunit.xml
inside php
tag you need to set a testing database like this
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.