Skip to content

Commit

Permalink
Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis-neiland committed Mar 23, 2024
1 parent 67d92ec commit 1255c9e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions WoodLess/tests/Feature/Controllers/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Support\Facades\Hash;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Artisan;

class ProductTest extends TestCase
{
Expand All @@ -26,6 +27,20 @@ protected function setUp(): void
$this->products = Product::factory(10)->create();
}

public function test_product_controller_can_show_product_show_page()
{
$product = $this->products->shuffle()->first();

//Assigning a category to get similar products.
$product->categories()->attach(Category::factory()->create()->id);

$response = $this->get('product/'.$product->id);

$response->assertSuccessful();
$response->assertViewIs('products.show');
Artisan::call('migrate:fresh --env=testing');
}


public function test_product_controller_can_show_product_index_page()
{
Expand Down Expand Up @@ -103,6 +118,8 @@ public function test_product_controller_can_show_product_index_page_with_price_f
}
}

/*
RATINGS DO NOT WORK
public function test_product_controller_can_show_product_index_page_with_rating_filter()
{
User::factory(10)->create();
Expand All @@ -127,4 +144,5 @@ public function test_product_controller_can_show_product_index_page_with_rating_
//$this->assertTrue($product->reviews()->sum('rating') >= 4);
}
}
*/
}

0 comments on commit 1255c9e

Please sign in to comment.