AttributeValueUnitTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Tests\Unit\AttributeValues;
  3. use App\Shop\Attributes\Attribute;
  4. use App\Shop\AttributeValues\AttributeValue;
  5. use App\Shop\AttributeValues\Repositories\AttributeValueRepository;
  6. use Tests\TestCase;
  7. class AttributeValueUnitTest extends TestCase
  8. {
  9. /** @test */
  10. public function it_can_be_dissociated_from_the_attribute()
  11. {
  12. $attributeValue = new AttributeValue(['value' => 'small']);
  13. $attributeValueRepo = new AttributeValueRepository($attributeValue);
  14. $attribute = factory(Attribute::class)->create();
  15. $createdValue = $attributeValueRepo->associateToAttribute($attribute);
  16. $attributeValueRepo2 = new AttributeValueRepository($createdValue);
  17. $removedAttribute = $attributeValueRepo2->dissociateFromAttribute();
  18. $this->assertTrue($removedAttribute);
  19. }
  20. /** @test */
  21. public function it_can_be_associated_with_the_attribute()
  22. {
  23. $attributeValue = new AttributeValue(['value' => 'sizes']);
  24. $attributeValueRepo = new AttributeValueRepository($attributeValue);
  25. $attribute = factory(Attribute::class)->create();
  26. $attributeValueRepo->associateToAttribute($attribute);
  27. $this->assertCount(1, $attribute->values->all());
  28. }
  29. }