Have you installed SQLite 3 on your computer? Have you uncommented both these lines in your phpunit.xml file?
<!-- <server name="DB_CONNECTION" value="sqlite"/> -->
<!-- <server name="DB_DATABASE" value=":memory:"/> -->
Hello, all my tests seem to be failing no matter what and im wondering if perhaps something is wrong with the code below.
Following this tutorial: https://laracasts.com/series/build-a-voting-app/episodes/10 I did everything as André himself said, we had to first and foremost create an idea via php artisan make:test IdeaShowTest command, afterwards uncomment this portion: <server name="DB_CONNECTION" value="sqlite"/> from phpunit.xml and then write the following code below:
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Idea;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ShowIdeasTest extends TestCase
{
use RefreshDatabase;
public function list_of_ideas_shows_on_main_page()
{
$ideaOne = Idea::factory()->create([
'title' => 'My First Idea',
'description' => 'Description of my first idea',
]);
$ideaTwo = Idea::factory()->create([
'title' => 'My Second Idea',
'description' => 'Description of my second idea',
]);
$response = $this->get(route('idea.index'));
$response->assertSuccessfull();
$response->assertSee($ideaOne->title);
$response->assertSee($ideaOne->description);
$response->assertSee($ideaTwo->title);
$response->assertSee($ideaTwo->description);
}
}
But as it turns out it's not working and I don't know why. I'll share with you a portion from the messages that I got, in total there should be 15 errors and it's obvious to me, seems like it wants to know about my database but Im at a loss here since this is my first time checking out the tests functionality within Laravel, so was there a database prerequisite other than uncommenting that line on phpunit.xml? Should I had added a new env var ? I read through the docs but couldn't find anything worth mentioning.. Please let me know, thanks!
3) Tests\Feature\Auth\AuthenticationTest::test_users_can_not_authenticate_with_invalid_password
Illuminate\Database\QueryException: Database (ratemyclip) does not exist. (SQL: PRAGMA foreign_keys = ON;)
Caused by
InvalidArgumentException: Database (ratemyclip) does not exist.
4) Tests\Feature\Auth\EmailVerificationTest::test_email_verification_screen_can_be_rendered
Illuminate\Database\QueryException: Database (ratemyclip) does not exist. (SQL: PRAGMA foreign_keys = ON;)
5) Tests\Feature\Auth\EmailVerificationTest::test_email_can_be_verified
Illuminate\Database\QueryException: Database (ratemyclip) does not exist. (SQL: PRAGMA foreign_keys = ON;)
Caused by
InvalidArgumentException: Database (ratemyclip) does not exist.
There was 1 warning:
1) Warning
No tests found in class "Tests\Feature\ShowIdeasTest".
ERRORS!
Tests: 16, Assertions: 0, Errors: 15, Warnings: 1.
Please or to participate in this conversation.