| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 | 
							- <?php
 
- namespace Tests\Unit\Attributes;
 
- use App\Shop\Attributes\Attribute;
 
- use App\Shop\Attributes\Exceptions\AttributeNotFoundException;
 
- use App\Shop\Attributes\Exceptions\CreateAttributeErrorException;
 
- use App\Shop\Attributes\Exceptions\UpdateAttributeErrorException;
 
- use App\Shop\Attributes\Repositories\AttributeRepository;
 
- use Tests\TestCase;
 
- class AttributeUnitTest extends TestCase
 
- {
 
-     /** @test */
 
-     public function it_should_error_when_the_attribute_is_not_found()
 
-     {
 
-         $this->expectException(AttributeNotFoundException::class);
 
-         $attributeRepo = new AttributeRepository(new Attribute);
 
-         $attributeRepo->findAttributeById(999);
 
-     }
 
-     /** @test */
 
-     public function it_should_show_the_attribute()
 
-     {
 
-         $attribute = factory(Attribute::class)->create();
 
-         $attributeRepo = new AttributeRepository(new Attribute);
 
-         $found = $attributeRepo->findAttributeById($attribute->id);
 
-         $this->assertInstanceOf(Attribute::class, $attribute);
 
-         $this->assertEquals($attribute->name, $found->name);
 
-     }
 
-     /** @test */
 
-     public function it_should_list_all_the_attributes()
 
-     {
 
-         factory(Attribute::class, 5)->create();
 
-         $attributeRepo = new AttributeRepository(new Attribute);
 
-         $list = $attributeRepo->listAttributes();
 
-         $this->assertCount(5, $list);
 
-     }
 
-     /** @test */
 
-     public function it_will_return_null_when_deleting_attribute_that_is_not_created_yet()
 
-     {
 
-         $attributeRepo = new AttributeRepository(new Attribute);
 
-         $delete = $attributeRepo->deleteAttribute();
 
-         $this->assertNull($delete);
 
-     }
 
-     
 
-     /** @test */
 
-     public function it_can_delete_the_attribute()
 
-     {
 
-         $attribute = factory(Attribute::class)->create();
 
-         $attributeRepo = new AttributeRepository($attribute);
 
-         $delete = $attributeRepo->deleteAttribute();
 
-         $this->assertTrue($delete);
 
-     }
 
-     /** @test */
 
-     public function it_errors_when_updating_attribute()
 
-     {
 
-         $this->expectException(UpdateAttributeErrorException::class);
 
-         $attribute = factory(Attribute::class)->create();
 
-         $attributeRepo = new AttributeRepository($attribute);
 
-         $attributeRepo->updateAttribute(['name' => null]);
 
-     }
 
-     /** @test */
 
-     public function it_can_update_the_attribute()
 
-     {
 
-         $attribute = factory(Attribute::class)->create();
 
-         $data = [
 
-             'name' => $this->faker->word
 
-         ];
 
-         $attributeRepo = new AttributeRepository($attribute);
 
-         $update = $attributeRepo->updateAttribute($data);
 
-         $this->assertTrue($update);
 
-         $this->assertEquals($data['name'], $attribute->name);
 
-     }
 
-     /** @test */
 
-     public function it_errors_when_creating_attribute()
 
-     {
 
-         $this->expectException(CreateAttributeErrorException::class);
 
-         $attributeRepo = new AttributeRepository(new Attribute);
 
-         $attributeRepo->createAttribute([]);
 
-     }
 
-     /** @test */
 
-     public function it_can_create_attribute()
 
-     {
 
-         $data = [
 
-             'name' => $this->faker->word
 
-         ];
 
-         $attributeRepo = new AttributeRepository(new Attribute);
 
-         $attribute = $attributeRepo->createAttribute($data);
 
-         $this->assertInstanceOf(Attribute::class, $attribute);
 
-         $this->assertEquals($data['name'], $attribute->name);
 
-     }
 
- }
 
 
  |