diff --git a/.circleci/config.yml b/.circleci/config.yml index d88ccdf2..ae8095a3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,6 +35,7 @@ jobs: # a collection of steps paths: - node_modules - run: touch database/testing.sqlite + - run: touch database/database.sqlite - run: php artisan migrate --env=testing --database=sqlite_testing --force - run: php artisan dusk:chrome-driver 70 - run: wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php index 85c41126..167138f6 100644 --- a/database/factories/ProductFactory.php +++ b/database/factories/ProductFactory.php @@ -31,6 +31,7 @@ public function definition() 'slug' => Str::slug($name), 'description' => $this->faker->realText(320), 'price' => $this->faker->numberBetween(100, 1000), + 'imageUrl' => $this->faker->imageUrl(400, 400), ]; } } diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index e5c5fef7..00000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,18 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Unit/ProductTest.php b/tests/Unit/ProductTest.php new file mode 100644 index 00000000..9a796e5a --- /dev/null +++ b/tests/Unit/ProductTest.php @@ -0,0 +1,39 @@ +create(); + + // Send a GET request to the /api/products endpoint + $response = $this->get('/api/products'); + + // Check that the response has a 200 status code + $response->assertStatus(200); + + // Check that the response contains the sample product data + $response->assertJsonPath('0.id', $product->id); + $response->assertJsonPath('0.name', $product->name); + $response->assertJsonPath('0.imageUrl', $product->imageUrl); + $response->assertJsonPath('0.slug', $product->slug); + $response->assertJsonPath('0.price', $product->price); + } +}