Exemplo n.º 1
0
 public function load(ObjectManager $manager)
 {
     $forum1 = new Forum();
     $forum1->setName('Skoler');
     $forum1->setDescription('Diskusjon for de ulike ungdommskolene');
     $forum1->setType("school");
     $manager->persist($forum1);
     $manager->flush();
     $this->addReference('forum-1', $forum1);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider getValidTestData
  */
 public function testForm($data)
 {
     $type = new CreateForumType();
     $form = $this->factory->create($type);
     $object = new Forum();
     $object->fromArray($data);
     // submit the data to the form directly
     $form->submit($data);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object, $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($data) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
Exemplo n.º 3
0
 public function testRemoveSubforum()
 {
     // new entity
     $forum = new Forum();
     $subforum1 = new Subforum();
     $subforum1->setName("Subforum1");
     $subforum2 = new Subforum();
     $subforum2->setName("Subforum2");
     $subforum3 = new Subforum();
     $subforum3->setName("Subforum3");
     // Use the addSubforum method
     $forum->addSubforum($subforum1);
     $forum->addSubforum($subforum2);
     $forum->addSubforum($subforum3);
     // Remove $subforum1
     $forum->removeSubforum($subforum1);
     // Subforums are stored in an array
     $subforums = $forum->getSubforums();
     // Loop through the array
     foreach ($subforums as $subforum) {
         // Assert the result
         $this->assertNotEquals($subforum1, $subforum);
     }
 }
Exemplo n.º 4
0
 /**
  * Displays a form to create a new Forum entity.
  *
  * @Route("/new/{id}", name="forum_new" , defaults={"id" = 1})
  * @Method("GET")
  * @Template("AppBundle:Shared:new.html.twig")
  */
 public function newAction($id)
 {
     $entity = new Forum();
     $em = $this->getDoctrine()->getManager();
     $parent = $em->getRepository('AppBundle:Forum')->find($id);
     $entity->setParent($parent);
     $form = $this->createCreateForm($entity);
     return array('entity' => $entity, 'form' => $form->createView());
 }
Exemplo n.º 5
0
 public function testRemoveForum()
 {
     // new entity
     $subforum = new Subforum();
     // New dummy entity
     $forum1 = new Forum();
     $forum1->setName("skole1");
     $forum2 = new Forum();
     $forum2->setName("skole2");
     $forum3 = new Forum();
     $forum3->setName("skole3");
     // Use the addForum method
     $subforum->addForum($forum1);
     $subforum->addForum($forum2);
     $subforum->addForum($forum3);
     // Remove $forum1 from department
     $subforum->removeForum($forum1);
     // forums is stored in an array
     $forums = $subforum->getForums();
     // Loop through the array
     foreach ($forums as $forum) {
         // Assert the result
         $this->assertNotEquals($forum1, $forum);
     }
 }