AttributeValuesFeatureTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Tests\Feature\Admin\AttributeValues;
  3. use App\Shop\Attributes\Attribute;
  4. use Tests\TestCase;
  5. class AttributeValuesFeatureTest extends TestCase
  6. {
  7. /** @test */
  8. public function it_can_remove_the_attribute_value()
  9. {
  10. $attribute = factory(Attribute::class)->create();
  11. $this
  12. ->actingAs($this->employee, 'employee')
  13. ->post(route('admin.attributes.values.store', $attribute->id), ['value' => 'test']);
  14. $this
  15. ->actingAs($this->employee, 'employee')
  16. ->delete(route('admin.attributes.values.destroy', [$attribute->id, 1]))
  17. ->assertStatus(302)
  18. ->assertRedirect(route('admin.attributes.show', $attribute->id))
  19. ->assertSessionHas('message', 'Attribute value removed!');
  20. }
  21. /** @test */
  22. public function it_can_store_the_attribute_values()
  23. {
  24. $attribute = factory(Attribute::class)->create();
  25. $this
  26. ->actingAs($this->employee, 'employee')
  27. ->post(route('admin.attributes.values.store', $attribute->id), ['value' => 'test'])
  28. ->assertStatus(302)
  29. ->assertRedirect(route('admin.attributes.show', $attribute->id))
  30. ->assertSessionHas('message', 'Attribute value created');
  31. }
  32. /** @test */
  33. public function it_can_sow_the_create_the_attribute_value_page()
  34. {
  35. $attribute = factory(Attribute::class)->create();
  36. $this
  37. ->actingAs($this->employee, 'employee')
  38. ->get(route('admin.attributes.values.create', $attribute->id))
  39. ->assertStatus(200)
  40. ->assertSee('Attribute value')
  41. ->assertSee($attribute->name);
  42. }
  43. }