Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions database/factories/ProductFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
}
}
18 changes: 0 additions & 18 deletions tests/Unit/ExampleTest.php

This file was deleted.

39 changes: 39 additions & 0 deletions tests/Unit/ProductTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Tests\Unit;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
use App\Models\Product;

class ProductTest extends TestCase
{
use RefreshDatabase;

/**
* Test the /api/products endpoint.
*
* This test sends a GET request to the /api/products endpoint and checks if
* the response has a 200 status code and contains the correct product data.
*
* @return void
*/
public function testApiProductsEndpoint()
{
// Create a sample product
$product = Product::factory()->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);
}
}