public function testSearch()
 {
     $description = "description";
     Category::create(array("description" => $description, "slug" => "slug", "slug_lang" => "slug"));
     $cat = $this->repo->search($description);
     $this->assertNotEmpty($cat);
     $cat = $this->repo->search("not found");
     $this->assertEmpty($cat);
 }
 /**
  * @test
  * @group duplicate
  **/
 public function it_duplicates_products_cats_imgs_accessories_and_create_unique_slug_lang()
 {
     // prepare product with related classes
     $this->prepareFakeData(2);
     $this->r->attachProduct(1, 2);
     Category::create(["description" => "descrizione", "slug" => "slug", "slug_lang" => "slug", "lang" => "it"]);
     $this->r->associateCategory(1, 1);
     $mock_img_repo = new ImgRepoStub();
     $img_data = ["description" => "desc", "product_id" => 1, "featured" => 0, "data" => 111];
     $mock_img_repo->create($img_data);
     $prod = $this->r->duplicate(1);
     // product duplicated
     $prod3 = $this->r->find(3);
     $prod1 = $this->r->find(1);
     // check that name contains copy
     $expected_name = $prod1->name . "_copia";
     $this->assertEquals($prod3->name, $expected_name);
     // check that i return a cloned product with no slug lang
     $this->assertEquals($prod->id, $prod->slug_lang);
     // categories
     $cat_original = $prod3->categories()->get()->lists('id');
     $cat_associated = $prod3->categories()->get()->lists('id');
     $this->assertEquals($cat_original, $cat_associated);
     // accessories
     $acc_original = $prod3->accessories()->get()->lists('id');
     $acc_associated = $prod3->accessories()->get()->lists('id');
     $this->assertEquals($acc_original, $acc_associated);
     // images
     $image_original = App::make('product_image_repository')->getByProductId($prod1->id);
     $image_associated = App::make('product_image_repository')->getByProductId($prod3->id);
     $this->assertEquals(count($image_original), count($image_associated));
     $this->assertEquals($image_original->first()->data, $image_associated->first()->data);
 }