Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Our First Test: Products Table - Empty or Not?

Premium
4:57

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

LD
LUIS DAVID CARDENAS BUCIO ✓ Link copied!

I want to mention that while I was writing my own tests, they were not running. The filename must end with 'Test,' and the functions within the class must begin with 'test' (respecting the lowercase and uppercase)

MB
mohannad banattaf ✓ Link copied!

my tests keep failing and i get this massage "Expected response status code [200] but received 500. Failed asserting that 500 is identical to 200.", also when i register from breeze dashboard and i go to '/products' it deletes my new accoute from the database and if i update the page i get this massage "Attempt to read property "name" on null" (this massage desipear when i register and login to the account but when im at the '/produtc' page and refresh it, it happens again and the accoute get deleted and i get the massage agian)

MB
mohannad banattaf ✓ Link copied!

Ok its simply due to NavBar trquesting Auth so when i put the navbar.blade as comment it worked

��
Артем Гаврюк ✓ Link copied!

If you have a "Expected response status code [200] but received 500"

just make your responses like this

$user = User::factory()->create();
$response = $this
    ->actingAs($user)
    ->get('/products');
KW
Konrad Wójcik ✓ Link copied!

This is my error message:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'testing.products' doesn't exist (Connection: mysql, SQL: insert into products (name, price, updated_at, created_at) values (Product 2, 12, 2024-04-24 19:44:59, 2024-04-24 19:44:59))

M
Modestas ✓ Link copied!

Did you run php artisan migrate after you created the migrations file?

KW
Konrad Wójcik ✓ Link copied!

i did but forcsome reason artisan wants to test testing database instead of laravel db. Migration populated laravel db