protected function setUp()
 {
     self::bootKernel(array('prepare_doctrine' => true));
     $manager = $this->getEntityManager();
     for ($i = 1; $i <= 50; $i++) {
         $entity = new TraitsEntity();
         $entity->setTitle(sprintf('Title %s', $i));
         $entity->setSummary(sprintf('Summary %s', $i));
         $manager->persist($entity);
     }
     $manager->flush();
 }
示例#2
0
 public function testTitleSlug()
 {
     $entity = new TraitsEntity();
     $this->assertNull($entity->getTitle());
     $this->assertNull($entity->getSlug());
     $entity->setTitle('Foo Bar');
     $manager = $this->getEntityManager();
     $manager->persist($entity);
     $manager->flush();
     $this->assertEquals('Foo Bar', $entity->getTitle());
     $this->assertEquals('foo-bar', $entity->getSlug());
     $this->assertNotNull($entity->getId());
     $id = $entity->getId();
     /** @var TraitsEntity $entity */
     $entity = $manager->getRepository('\\Kyoushu\\CommonBundle\\Tests\\Entity\\TraitsEntity')->find($id);
     $this->assertNotNull($entity);
     $this->assertEquals('Foo Bar', $entity->getTitle());
     $this->assertEquals('foo-bar', $entity->getSlug());
 }