FAIL Tests\Feature\AuthTest ✓ user can register 0.22s ✓ user cannot register with invalid email 0.01s ✓ user cannot register with duplicate email 0.06s ⨯ user can login 0.03s ✓ user cannot login with wrong credentials 0.22s ⨯ user can logout 0.03s ⨯ user can get profile 0.01s ✓ unauthenticated user cannot access protected routes 0.01s FAIL Tests\Feature\CategoryTest ⨯ can get all categories 0.02s ⨯ can create category 0.01s ⨯ can create category with image 0.02s ⨯ cannot create category without name 0.01s ⨯ can get single category 0.01s ⨯ can update category 0.01s ⨯ can update category image 0.01s ⨯ can delete category 0.01s ⨯ returns 404 for non existent category 0.01s ✓ unauthenticated user cannot access categories 0.01s PASS Tests\Feature\ExampleTest ✓ the application returns a successful response 0.03s FAIL Tests\Feature\ProductTest ⨯ can get all products 0.01s ⨯ can create single product 0.01s ⨯ can create multiple products 0.01s ⨯ can create product with images 0.01s ⨯ first image is marked as primary 0.01s ⨯ cannot create product without required fields 0.01s ⨯ can get single product 0.01s ⨯ can update product 0.01s ⨯ can add images to existing product 0.01s ⨯ can remove product images 0.01s ⨯ can delete product 0.01s ⨯ returns 404 for non existent product 0.01s ✓ unauthenticated user cannot access products 0.01s ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\AuthTest > user can login Expected response status code [200] but received 500. Failed asserting that 500 is identical to 200. at tests/Feature/AuthTest.php:82 78▕ 'email' => 'test@example.com', 79▕ 'password' => 'password123', 80▕ ]); 81▕ ➜ 82▕ $response->assertStatus(200) 83▕ ->assertJsonStructure([ 84▕ 'access_token', 85▕ 'token_type', 86▕ 'expires_in', ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\AuthTest > user can logout Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/AuthTest.php:114 110▕ $response = $this->withHeaders([ 111▕ 'Authorization' => 'Bearer ' . $token, 112▕ ])->postJson('/api/v4/logout'); 113▕ ➜ 114▕ $response->assertStatus(200) 115▕ ->assertJson([ 116▕ 'status' => 'success', 117▕ ]); 118▕ } ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\AuthTest > user can get profile Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/AuthTest.php:132 128▕ $response = $this->withHeaders([ 129▕ 'Authorization' => 'Bearer ' . $token, 130▕ ])->getJson('/api/v4/me'); 131▕ ➜ 132▕ $response->assertStatus(200) 133▕ ->assertJson([ 134▕ 'status' => 'success', 135▕ 'data' => [ 136▕ 'id' => $user->id, ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > can get all categories Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/CategoryTest.php:38 34▕ $response = $this->withHeaders([ 35▕ 'Authorization' => 'Bearer ' . $this->token, 36▕ ])->getJson('/api/v4/categories'); 37▕ ➜ 38▕ $response->assertStatus(200) 39▕ ->assertJson([ 40▕ 'status' => 'success', 41▕ ]) 42▕ ->assertJsonStructure([ ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > can create category Expected response status code [201] but received 401. Failed asserting that 401 is identical to 201. at tests/Feature/CategoryTest.php:68 64▕ 'description' => 'Test Description', 65▕ 'status' => 'ENABLE', 66▕ ]); 67▕ ➜ 68▕ $response->assertStatus(201) 69▕ ->assertJson([ 70▕ 'status' => 'success', 71▕ 'data' => [ 72▕ 'name' => 'Test Category', ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > can create category with image Expected response status code [201] but received 401. Failed asserting that 401 is identical to 201. at tests/Feature/CategoryTest.php:96 92▕ 'description' => 'Has an image', 93▕ 'image' => $file, 94▕ ]); 95▕ ➜ 96▕ $response->assertStatus(201); 97▕ Storage::disk('public')->assertExists('categories/' . $file->hashName()); 98▕ } 99▕ 100▕ public function test_cannot_create_category_without_name(): void ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > cannot create category without name Expected response status code [422] but received 401. Failed asserting that 401 is identical to 422. at tests/Feature/CategoryTest.php:108 104▕ ])->postJson('/api/v4/categories', [ 105▕ 'description' => 'Test Description', 106▕ ]); 107▕ ➜ 108▕ $response->assertStatus(422); 109▕ } 110▕ 111▕ public function test_can_get_single_category(): void 112▕ { ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > can get single category Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/CategoryTest.php:122 118▕ $response = $this->withHeaders([ 119▕ 'Authorization' => 'Bearer ' . $this->token, 120▕ ])->getJson('/api/v4/categories/' . $category->id); 121▕ ➜ 122▕ $response->assertStatus(200) 123▕ ->assertJson([ 124▕ 'status' => 'success', 125▕ 'data' => [ 126▕ 'id' => $category->id, ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > can update category Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/CategoryTest.php:146 142▕ 'name' => 'Updated Name', 143▕ 'description' => 'Updated Description', 144▕ ]); 145▕ ➜ 146▕ $response->assertStatus(200) 147▕ ->assertJson([ 148▕ 'status' => 'success', 149▕ 'data' => [ 150▕ 'name' => 'Updated Name', ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > can update category image Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/CategoryTest.php:181 177▕ 'name' => $category->name, 178▕ 'image' => $newFile, 179▕ ]); 180▕ ➜ 181▕ $response->assertStatus(200); 182▕ Storage::disk('public')->assertExists('categories/' . $newFile->hashName()); 183▕ } 184▕ 185▕ public function test_can_delete_category(): void ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > can delete category Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/CategoryTest.php:195 191▕ $response = $this->withHeaders([ 192▕ 'Authorization' => 'Bearer ' . $this->token, 193▕ ])->deleteJson('/api/v4/categories/' . $category->id); 194▕ ➜ 195▕ $response->assertStatus(200) 196▕ ->assertJson([ 197▕ 'status' => 'success', 198▕ ]); 199▕ ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\CategoryTest > returns 404 for non existent categor… Expected response status code [404] but received 401. Failed asserting that 401 is identical to 404. at tests/Feature/CategoryTest.php:211 207▕ $response = $this->withHeaders([ 208▕ 'Authorization' => 'Bearer ' . $this->token, 209▕ ])->getJson('/api/v4/categories/99999'); 210▕ ➜ 211▕ $response->assertStatus(404); 212▕ } 213▕ 214▕ public function test_unauthenticated_user_cannot_access_categories(): void 215▕ { ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can get all products Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/ProductTest.php:45 41▕ $response = $this->withHeaders([ 42▕ 'Authorization' => 'Bearer ' . $this->token, 43▕ ])->getJson('/api/v4/products'); 44▕ ➜ 45▕ $response->assertStatus(200) 46▕ ->assertJson([ 47▕ 'status' => 'success', 48▕ ]) 49▕ ->assertJsonStructure([ ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can create single product Expected response status code [201] but received 401. Failed asserting that 401 is identical to 201. at tests/Feature/ProductTest.php:84 80▕ ] 81▕ ] 82▕ ]); 83▕ ➜ 84▕ $response->assertStatus(201) 85▕ ->assertJson([ 86▕ 'status' => 'success', 87▕ 'data' => [ 88▕ [ ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can create multiple products Expected response status code [201] but received 401. Failed asserting that 401 is identical to 201. at tests/Feature/ProductTest.php:127 123▕ ], 124▕ ] 125▕ ]); 126▕ ➜ 127▕ $response->assertStatus(201) 128▕ ->assertJsonCount(3, 'data'); 129▕ 130▕ $this->assertDatabaseHas('products', ['name' => 'Product 1']); 131▕ $this->assertDatabaseHas('products', ['name' => 'Product 2']); ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can create product with images Expected response status code [201] but received 401. Failed asserting that 401 is identical to 201. at tests/Feature/ProductTest.php:153 149▕ ] 150▕ ] 151▕ ]); 152▕ ➜ 153▕ $response->assertStatus(201); 154▕ 155▕ $product = Product::where('name', 'Product with Images')->first(); 156▕ $this->assertNotNull($product); 157▕ $this->assertEquals(2, $product->images()->count()); ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > first image is marked as primary Expected response status code [201] but received 401. Failed asserting that 401 is identical to 201. at tests/Feature/ProductTest.php:181 177▕ ] 178▕ ] 179▕ ]); 180▕ ➜ 181▕ $response->assertStatus(201); 182▕ 183▕ $product = Product::where('name', 'Product Primary Image')->first(); 184▕ $primaryImage = $product->images()->where('is_primary', true)->first(); 185▕ $this->assertNotNull($primaryImage); ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > cannot create product without require… Expected response status code [422] but received 401. Failed asserting that 401 is identical to 422. at tests/Feature/ProductTest.php:200 196▕ ] 197▕ ] 198▕ ]); 199▕ ➜ 200▕ $response->assertStatus(422); 201▕ } 202▕ 203▕ public function test_can_get_single_product(): void 204▕ { ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can get single product Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/ProductTest.php:215 211▕ $response = $this->withHeaders([ 212▕ 'Authorization' => 'Bearer ' . $this->token, 213▕ ])->getJson('/api/v4/products/' . $product->id); 214▕ ➜ 215▕ $response->assertStatus(200) 216▕ ->assertJson([ 217▕ 'status' => 'success', 218▕ 'data' => [ 219▕ 'id' => $product->id, ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can update product Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/ProductTest.php:241 237▕ 'name' => 'Updated Name', 238▕ 'price' => 150000, 239▕ ]); 240▕ ➜ 241▕ $response->assertStatus(200) 242▕ ->assertJson([ 243▕ 'status' => 'success', 244▕ 'data' => [ 245▕ 'name' => 'Updated Name', ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can add images to existing product Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/ProductTest.php:274 270▕ 'name' => $product->name, 271▕ 'images' => [$file1, $file2], 272▕ ]); 273▕ ➜ 274▕ $response->assertStatus(200); 275▕ 276▕ $this->assertEquals(2, $product->fresh()->images()->count()); 277▕ Storage::disk('public')->assertExists('products/' . $file1->hashName()); 278▕ Storage::disk('public')->assertExists('products/' . $file2->hashName()); ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can remove product images Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/ProductTest.php:310 306▕ 'name' => $product->name, 307▕ 'remove_images' => [$image1->id], 308▕ ]); 309▕ ➜ 310▕ $response->assertStatus(200); 311▕ 312▕ $this->assertDatabaseMissing('product_images', ['id' => $image1->id]); 313▕ $this->assertDatabaseHas('product_images', ['id' => $image2->id]); 314▕ } ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > can delete product Expected response status code [200] but received 401. Failed asserting that 401 is identical to 200. at tests/Feature/ProductTest.php:334 330▕ $response = $this->withHeaders([ 331▕ 'Authorization' => 'Bearer ' . $this->token, 332▕ ])->deleteJson('/api/v4/products/' . $product->id); 333▕ ➜ 334▕ $response->assertStatus(200) 335▕ ->assertJson([ 336▕ 'status' => 'success', 337▕ ]); 338▕ ──────────────────────────────────────────────────────────────────────────── FAILED Tests\Feature\ProductTest > returns 404 for non existent product Expected response status code [404] but received 401. Failed asserting that 401 is identical to 404. at tests/Feature/ProductTest.php:350 346▕ $response = $this->withHeaders([ 347▕ 'Authorization' => 'Bearer ' . $this->token, 348▕ ])->getJson('/api/v4/products/99999'); 349▕ ➜ 350▕ $response->assertStatus(404); 351▕ } 352▕ 353▕ public function test_unauthenticated_user_cannot_access_products(): void 354▕ { Tests: 24 failed, 8 passed (42 assertions) Duration: 0.94s