public function testRemovePage() { $page = new Page(); $page->setTitle('Test')->setContent('<p>test</p>')->setCurrentSlugUrl('/remove'); $this->entityManager->persist($page); $childPage1 = new Page(); $childPage1->setTitle('Test child Page 1')->setContent('<p>test child page</p>')->setCurrentSlugUrl('/child1'); $this->entityManager->persist($childPage1); $childPage2 = new Page(); $childPage2->setTitle('Test child Page 2')->setContent('<p>test child page</p>')->setCurrentSlugUrl('/child2'); $this->entityManager->persist($childPage2); $page->addChildPage($childPage1); $page->addChildPage($childPage2); $this->entityManager->flush($page); $pageSlugId = $page->getCurrentSlug()->getId(); $childPage1SlugId = $childPage1->getCurrentSlug()->getId(); $childPage2SlugId = $childPage2->getCurrentSlug()->getId(); $this->entityManager->remove($page); $this->entityManager->flush(); // make sure data updated correctly $this->entityManager->clear(); $this->assertNull($this->entityManager->find('OroB2BRedirectBundle:Slug', $pageSlugId)); $this->assertNull($this->entityManager->find('OroB2BRedirectBundle:Slug', $childPage1SlugId)); $this->assertNull($this->entityManager->find('OroB2BRedirectBundle:Slug', $childPage2SlugId)); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst(); $locator = $this->container->get('file_locator'); $filePath = $locator->locate('@OroB2BCMSBundle/Migrations/Data/Demo/ORM/data/pages.csv'); if (is_array($filePath)) { $filePath = current($filePath); } $handler = fopen($filePath, 'r'); $headers = fgetcsv($handler, 5000, ','); while (($data = fgetcsv($handler, 5000, ',')) !== false) { $row = array_combine($headers, array_values($data)); $page = new Page(); $page->setTitle($row['title']); $page->setContent($row['content']); $page->setOrganization($organization); $page->setCurrentSlugUrl($row['slug']); if ($row['parentId'] > 0 && array_key_exists($row['parentId'], $this->pages)) { /** @var Page $parent */ $parent = $this->pages[$row['parentId']]; $parent->addChildPage($page); } $manager->persist($page); $this->pages[$row['id']] = $page; } fclose($handler); $manager->flush(); }
public function testToString() { $value = 'test'; $page = new Page(); $page->setTitle($value); $this->assertEquals($value, (string) $page); }