Ejemplo n.º 1
0
 public function testSetBlog()
 {
     $comment = new Comment();
     $blog = new Blog();
     $comment->setBlog($blog);
     $this->assertEquals($blog, $comment->getBlog());
 }
 /**
  * @expectedException \Doctrine\DBAL\DBALException
  */
 public function testNoCommentException()
 {
     $comment = new Comment();
     $comment->setUser('tester');
     $this->em->persist($comment);
     $this->em->flush();
 }
Ejemplo n.º 3
0
 public function postBlogCommentAction()
 {
     $request = $this->getRequest();
     $em = $this->getDoctrine()->getEntityManager();
     $blog = $em->find('KoiosBlogBackendBundle:Blog', $request->get('id'));
     $comment = new Comment();
     $comment->setBlog($blog);
     $comment->setUser($request->get('user'));
     $comment->setComment($request->get('comment'));
     $em->persist($comment);
     $em->flush();
     new Response(Codes::HTTP_CREATED);
 }
Ejemplo n.º 4
0
 public function load(ObjectManager $manager)
 {
     $comment = new Comment();
     $comment->setUser('symfony');
     $comment->setComment('To make a long story short. You can\'t go wrong by choosing Symfony! And no one has ever been fired for using Symfony.');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $comment->setApproved(false);
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('David');
     $comment->setComment('To make a long story short. Choosing a framework must not be taken lightly; it is a long-term commitment. Make sure that you make the right selection!');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Anything else, mom? You want me to mow the lawn? Oops! I forgot, New York, No grass.');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Are you challenging me? ');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-23 06:15:20"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Name your stakes.');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-23 06:18:35"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('If I win, you become my slave.');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-23 06:22:53"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Your SLAVE?');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-23 06:25:15"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('You wish! You\'ll do shitwork, scan, crack copyrights...');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-23 06:46:08"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('And if I win?');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-23 10:22:46"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Make it my first-born!');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-23 11:08:08"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Make it our first-date!');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-24 18:56:01"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('I don\'t DO dates. But I don\'t lose either, so you\'re on!');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $comment->setCreated(new \DateTime("2011-07-25 22:28:42"));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Stanley');
     $comment->setComment('It\'s not gonna end like this.');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Gabriel');
     $comment->setComment('Oh, come on, Stan. Not everything ends the way you think it should. Besides, audiences love happy endings.');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Mile');
     $comment->setComment('Doesn\'t Bill Gates have something like that?');
     $comment->setBlog($manager->merge($this->getReference('blog-5')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Gary');
     $comment->setComment('Bill Who?');
     $comment->setBlog($manager->merge($this->getReference('blog-5')));
     $manager->persist($comment);
     $manager->flush();
 }