CustomerAddressFeatureTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Tests\Feature\Front\CustomerAddresses;
  3. use App\Shop\Addresses\Address;
  4. use App\Shop\Cities\City;
  5. use App\Shop\Countries\Country;
  6. use App\Shop\Customers\Repositories\CustomerRepository;
  7. use App\Shop\Provinces\Province;
  8. use Tests\TestCase;
  9. class CustomerAddressFeatureTest extends TestCase
  10. {
  11. /** @test */
  12. public function it_can_show_the_list_of_address_of_the_customer()
  13. {
  14. $address = factory(Address::class)->create();
  15. $customerRepo = new CustomerRepository($this->customer);
  16. $customerRepo->attachAddress($address);
  17. $this
  18. ->actingAs($this->customer, 'web')
  19. ->get(route('customer.address.index', $this->customer->id))
  20. ->assertStatus(302)
  21. ->assertRedirect(route('accounts', ['tab' => 'address']));
  22. }
  23. /** @test */
  24. public function it_can_save_the_customer_address()
  25. {
  26. $country = factory(Country::class)->create();
  27. $province = factory(Province::class)->create([
  28. 'country_id' => $country->id
  29. ]);
  30. $city = factory(City::class)->create([
  31. 'province_id' => $province->id
  32. ]);
  33. $data = [
  34. 'status' => 1,
  35. 'alias' => 'home',
  36. 'address_1' => $this->faker->address,
  37. 'city_id' => $city->id,
  38. 'province_id' => $province->id,
  39. 'customer_id' => $this->customer->id,
  40. 'country_id' => $country->id
  41. ];
  42. $this
  43. ->actingAs($this->customer, 'web')
  44. ->post(route('customer.address.store', $this->customer->id), $data)
  45. ->assertStatus(302)
  46. ->assertRedirect(route('accounts', ['tab' => 'address']));
  47. }
  48. /** @test */
  49. public function it_can_show_the_create_address()
  50. {
  51. factory(City::class)->create();
  52. $this
  53. ->actingAs($this->customer, 'web')
  54. ->get(route('customer.address.create', $this->customer->id))
  55. ->assertStatus(200)
  56. ->assertSee('Alias')
  57. ->assertSee('Address 1')
  58. ->assertSee('Address 2')
  59. ->assertSee('Country')
  60. ->assertSee('Province')
  61. ->assertSee('City')
  62. ->assertSee('Zip Code');
  63. }
  64. }