File tree Expand file tree Collapse file tree 4 files changed +41
-18
lines changed Expand file tree Collapse file tree 4 files changed +41
-18
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ jobs: # a collection of steps
35
35
paths :
36
36
- node_modules
37
37
- run : touch database/testing.sqlite
38
+ - run : touch database/database.sqlite
38
39
- run : php artisan migrate --env=testing --database=sqlite_testing --force
39
40
- run : php artisan dusk:chrome-driver 70
40
41
- run : wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ public function definition()
31
31
'slug ' => Str::slug ($ name ),
32
32
'description ' => $ this ->faker ->realText (320 ),
33
33
'price ' => $ this ->faker ->numberBetween (100 , 1000 ),
34
+ 'imageUrl ' => $ this ->faker ->imageUrl (400 , 400 ),
34
35
];
35
36
}
36
37
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests \Unit ;
4
+
5
+ use Illuminate \Foundation \Testing \RefreshDatabase ;
6
+ use Tests \TestCase ;
7
+ use App \Models \Product ;
8
+
9
+ class ProductTest extends TestCase
10
+ {
11
+ use RefreshDatabase;
12
+
13
+ /**
14
+ * Test the /api/products endpoint.
15
+ *
16
+ * This test sends a GET request to the /api/products endpoint and checks if
17
+ * the response has a 200 status code and contains the correct product data.
18
+ *
19
+ * @return void
20
+ */
21
+ public function testApiProductsEndpoint ()
22
+ {
23
+ // Create a sample product
24
+ $ product = Product::factory ()->create ();
25
+
26
+ // Send a GET request to the /api/products endpoint
27
+ $ response = $ this ->get ('/api/products ' );
28
+
29
+ // Check that the response has a 200 status code
30
+ $ response ->assertStatus (200 );
31
+
32
+ // Check that the response contains the sample product data
33
+ $ response ->assertJsonPath ('0.id ' , $ product ->id );
34
+ $ response ->assertJsonPath ('0.name ' , $ product ->name );
35
+ $ response ->assertJsonPath ('0.imageUrl ' , $ product ->imageUrl );
36
+ $ response ->assertJsonPath ('0.slug ' , $ product ->slug );
37
+ $ response ->assertJsonPath ('0.price ' , $ product ->price );
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments