FrontProductFeatureTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Tests\Feature\Front\Products;
  3. use App\Shop\Products\Product;
  4. use Tests\TestCase;
  5. class FrontProductFeatureTest extends TestCase
  6. {
  7. /** @test */
  8. public function it_can_show_the_product()
  9. {
  10. $product = factory(Product::class)->create();
  11. $this
  12. ->get(route('front.get.product', str_slug($product->name)))
  13. ->assertStatus(200)
  14. ->assertSee($product->name)
  15. ->assertSee($product->description)
  16. ->assertSee("$product->quantity")
  17. ->assertSee("$product->price");
  18. }
  19. /** @test */
  20. public function it_should_not_throw_error_even_the_query_is_empty()
  21. {
  22. $product = factory(Product::class)->create();
  23. $this
  24. ->get(route('search.product', ['q' => '']))
  25. ->assertStatus(200)
  26. ->assertSee($product->name)
  27. ->assertSee("$product->quantity")
  28. ->assertSee("$product->price");
  29. }
  30. /** @test */
  31. public function it_can_search_for_a_product()
  32. {
  33. $product = factory(Product::class)->create();
  34. $this
  35. ->get(route('search.product', ['q' => str_limit($product->name, 4, '')]))
  36. ->assertStatus(200)
  37. ->assertSee($product->name)
  38. ->assertSee("$product->quantity")
  39. ->assertSee("$product->price");
  40. }
  41. }