示例#1
0
 public function testDuplicateImages()
 {
     $image = new Image();
     $image->setFilename($this->faker->numberBetween(0, 10000));
     $image->setMainImage(false);
     $this->dm->persist($image);
     $this->dm->flush();
     $this->assertNotNull($image->getId());
     $product = new Product();
     $product->setLocale('en');
     $product->setName($this->faker->sentence(1));
     $product->setDescriptionShort($this->faker->sentence(10));
     $product->setDescription($this->faker->sentence(10));
     $product->setStatus(true);
     $product->setCommentStatus(true);
     $product->setMetaUrl('url_' . time());
     $product->addImage($image);
     $product->addImage($image);
     $this->dm->persist($product);
     $this->dm->flush();
     $this->assertNotNull($product->getId());
     $this->assertEquals(count($product->getImages()), 1);
     $this->dm->remove($image);
     $this->dm->flush();
     $this->dm->remove($product);
     $this->dm->flush();
 }