Beispiel #1
0
 public function testDuplicateImages()
 {
     $user = $this->em->getRepository('Aisel\\UserBundle\\Entity\\User')->findOneBy(['email' => '*****@*****.**']);
     $this->setExpectedException('Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException');
     $image = new Media();
     $image->setType(Media::MEDIA_IMAGE);
     $image->setFilename($this->faker->numberBetween(0, 10000));
     $image->setMainImage(false);
     $this->em->persist($image);
     $this->em->flush();
     $this->assertNotNull($image->getId());
     $product = new Product();
     $product->setUser($user);
     $product->setLocale('en');
     $product->setName($this->faker->sentence(1));
     $product->setContentShort($this->faker->sentence(10));
     $product->setContent($this->faker->sentence(10));
     $product->setStatus(true);
     $product->setSku($this->faker->numberBetween());
     $product->setCommentStatus(true);
     $product->setMetaUrl('url_' . time());
     $product->addMedia($image);
     $product->addMedia($image);
     $this->em->persist($product);
     $this->em->flush();
 }