public function testDelete() { $em = $this->em; $entity = new AdminPage(); $entity->setCurrentLocale($this->locale); $entity->setTitle('Title Delete - phpunit'); $entity->setBody('Body'); $entity->setVisible(true); $em->persist($entity); $em->flush(); $id = $entity->getId(); $this->logIn(); $client = $this->client; $token = $this->generateToken('ojs_admin_page' . $id); $client->request('DELETE', '/admin/page/' . $id . '/delete', array('_token' => $token)); $this->assertStatusCode(302, $client); }
protected function createDefaultPages() { $pages = [['about', 'About', 'About page content goes here.'], ['privacy', 'Privacy', 'Privacy page content goes here.'], ['faq', 'FAQ', 'A list of frequently answered questions goes here.'], ['tos', 'Terms of Service', 'TOS page content goes here.']]; $em = $this->getContainer()->get('doctrine')->getManager(); foreach ($pages as $page) { $entity = $em->getRepository('OjsAdminBundle:AdminPage')->findOneBy(['slug' => $page[0]]); if (!$entity) { $entity = new AdminPage(); $entity->setVisible(true); $entity->setCurrentLocale($this->getContainer()->getParameter('locale')); $entity->setSlug($page[0]); $entity->setTitle($page[1]); $entity->setBody($page[2]); $em->persist($entity); } } $em->flush(); }