コード例 #1
0
    public function testStaticContent()
    {
        $data = array(
            'name' => 'test-node',
            'title' => 'test-title',
            'body' => 'test-body',
            'publishable' => false,
            'publishStartDate' => new \DateTime('2013-06-18'),
            'publishEndDate' => new \DateTime('2013-06-18'),
        );

        $content = new StaticContent;
        $refl = new \ReflectionClass($content);

        $content->setParentDocument($this->base);

        foreach ($data as $key => $value) {
            $refl = new \ReflectionClass($content);
            $prop = $refl->getProperty($key);
            $prop->setAccessible(true);
            $prop->setValue($content, $value);
        }

        $this->dm->persist($content);
        $this->dm->flush();
        $this->dm->clear();

        $content = $this->dm->find(null, '/test/test-node');

        $this->assertNotNull($content);

        foreach ($data as $key => $value) {
            $prop = $refl->getProperty($key);
            $prop->setAccessible(true);
            $v = $prop->getValue($content);

            if (!is_object($value)) {
                $this->assertEquals($value, $v);
            }
        }

        // test publish start and end
        $publishStartDate = $content->getPublishStartDate();
        $publishEndDate = $content->getPublishEndDate();

        $this->assertInstanceOf('\DateTime', $publishStartDate);
        $this->assertInstanceOf('\DateTime', $publishEndDate);
        $this->assertEquals($data['publishStartDate']->format('Y-m-d'), $publishStartDate->format('Y-m-d'));
        $this->assertEquals($data['publishEndDate']->format('Y-m-d'), $publishEndDate->format('Y-m-d'));

        // test multi-lang
        $content->setLocale('fr');
        $this->dm->persist($content);
        $this->dm->flush();
        $this->dm->clear();

        $content = $this->dm->findTranslation(null, '/test/test-node', 'fr');
        $this->assertEquals('fr', $content->getLocale());
    }
コード例 #2
0
 public function testSubmitValidData()
 {
     $data = ['name' => 'hello-world', 'parentDocument' => '/cms/content'];
     $document = $this->getMock(Generic::class);
     $this->documentManager->expects($this->once())->method('find')->with(null, $data['parentDocument'])->will($this->returnValue($document));
     $form = $this->factory->create(StaticContentType::class);
     $form->submit($data);
     $object = new StaticContent();
     $object->setName($data['name']);
     $object->setParentDocument($document);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object, $form->getData());
 }
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager|DocumentManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $contentParent = $manager->find(null, '/cms/content');
     $routeParent = $manager->find(null, '/cms/routes');
     $menuBase = $manager->find(null, '/cms/menu');
     $enRoute = new Route();
     $enRoute->setPosition($routeParent, 'en');
     $manager->persist($enRoute);
     $deRoute = new Route();
     $deRoute->setPosition($routeParent, 'de');
     $manager->persist($deRoute);
     $enServiceRoute = new Route();
     $enServiceRoute->setPosition($enRoute, 'services');
     $manager->persist($enServiceRoute);
     $deServiceRoute = new Route();
     $deServiceRoute->setPosition($deRoute, 'dienstleistungen');
     $manager->persist($deServiceRoute);
     $content = new StaticContent();
     $content->setParentDocument($contentParent);
     $content->setName('symfony-service');
     $manager->persist($content);
     $content->setTitle('Symfony Service');
     $content->setBody('A page about Symfony service');
     $manager->bindTranslation($content, 'en');
     $contentRoute = new Route();
     $contentRoute->setPosition($enServiceRoute, 'symfony-service');
     $contentRoute->setContent($content);
     $manager->persist($contentRoute);
     $content->setTitle('Symfony Dienstleistungen');
     $content->setBody('Eine Seite über Symfony Dienstleistungen');
     $manager->bindTranslation($content, 'de');
     $contentRoute = new Route();
     $contentRoute->setPosition($deServiceRoute, 'symfony-dienstleistungen');
     $contentRoute->setContent($content);
     $manager->persist($contentRoute);
     $menu = new Menu();
     $menu->setPosition($menuBase, 'footer');
     $manager->persist($menu);
     $menuNode = new MenuNode();
     $menuNode->setParentDocument($menu);
     $menuNode->setContent($content);
     $menuNode->setName('symfony-service');
     $manager->persist($menuNode);
     $menuNode->setLabel('Symfony Services');
     $manager->bindTranslation($menuNode, 'en');
     $menuNode->setLabel('Symfony Dienstleistungen');
     $manager->bindTranslation($menuNode, 'de');
     $manager->flush();
 }
コード例 #4
0
    public function load(ObjectManager $manager)
    {
        NodeHelper::createPath($manager->getPhpcrSession(), '/test');
        $root = $manager->find(null, '/test');

        $contentRoot = new Generic;
        $contentRoot->setNodename('contents');
        $contentRoot->setParent($root);
        $manager->persist($contentRoot);

        $content = new StaticContent;
        $content->setName('content-1');
        $content->setTitle('Content 1');
        $content->setBody('Content 1');
        $content->setParentDocument($contentRoot);
        $manager->persist($content);

        $content = new StaticContent;
        $content->setName('content-2');
        $content->setTitle('Content 2');
        $content->setBody('Content 2');
        $content->setParentDocument($contentRoot);
        $manager->persist($content);

        $manager->flush();
    }
コード例 #5
0
 public function __construct()
 {
     $this->seoMetadata = new SeoMetadata();
     parent::__construct();
 }
コード例 #6
0
 public function __construct($name = null)
 {
     parent::__construct();
     $this->children = new ArrayCollection();
 }