StateFeatureTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Tests\Feature\Front\States;
  3. use App\Shop\Cities\City;
  4. use App\Shop\Countries\Country;
  5. use App\Shop\States\State;
  6. use Tests\TestCase;
  7. class StateFeatureTest extends TestCase
  8. {
  9. /** @test */
  10. public function it_can_list_cities()
  11. {
  12. $country = factory(Country::class)->create([
  13. 'name' => 'United States of America',
  14. 'iso' => 'US'
  15. ]);
  16. $usState = factory(State::class)->create([
  17. 'country_id' => $country->id
  18. ]);
  19. $city = factory(City::class)->create([
  20. 'state_code' => $usState->state_code
  21. ]);
  22. $this->actingAs($this->customer)
  23. ->get(route('state.city.index', $usState->state_code))
  24. ->assertJsonFragment(['name' => $city->name])
  25. ->assertStatus(200);
  26. }
  27. /** @test */
  28. public function it_can_list_all_the_states()
  29. {
  30. $country = factory(Country::class)->create([
  31. 'name' => $this->faker->country,
  32. 'iso' => 'US'
  33. ]);
  34. $usState = factory(State::class)->create([
  35. 'country_id' => $country->id,
  36. ]);
  37. $this->actingAs($this->customer)
  38. ->get(route('country.state.index', $country->id))
  39. ->assertJsonFragment(['state' => $usState->state])
  40. ->assertStatus(200);
  41. }
  42. }