Ejemplo n.º 1
0
 /**
  * (non-PHPdoc)
  * @see Doctrine\Common\DataFixtures.FixtureInterface::load()
  */
 public function load(ObjectManager $manager)
 {
     $news = new News();
     $news->setTitle('News title');
     $news->setContent('News content www.google.it');
     $news->getChannels()->add($this->getReference('laureati-channel'));
     $news->getChannels()->add($this->getReference('ingegneria-channel'));
     $news->setUser($this->getReference('admin-user'));
     $news->setDeleted(false);
     $manager->persist($news);
     $manager->flush();
 }
Ejemplo n.º 2
0
 public function testDelete()
 {
     $client = static::createClient();
     $em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
     $channel = $em->getRepository('UniversiboCoreBundle:Channel')->find(3);
     $news = new News();
     $news->setTitle('Delete me title');
     $news->setContent('Delete me content');
     $news->setCreatedAt(new \DateTime());
     $news->setUpdatedAt(new \DateTime());
     $news->getChannels()->add($channel);
     $em->persist($news);
     $em->flush();
     $this->login($client);
     $crawler = $client->request('GET', '/news/' . $news->getId() . '/show');
     $form = $crawler->selectButton('Delete')->form();
     $crawler = $client->submit($form);
     $this->assertTrue($client->getResponse()->isRedirect(), 'Expecting redirect response');
 }