コード例 #1
0
 public function testFindNewArticle()
 {
     $manager = $this->getContainer()->get('doctrine_phpcr.odm.document_manager');
     $article = new Article();
     $article->setTitle('Test Article');
     $article->setContent('Test Article lipsum');
     $manager->persist($article);
     $manager->flush();
     $articleLoader = new ArticleLoader($this->getContainer()->getParameter('kernel.root_dir'), $this->getContainer()->get('doctrine_phpcr.odm.document_manager'), $this->getContainer()->get('doctrine.orm.entity_manager'));
     $this->assertTrue($articleLoader->isSupported('article'));
     $this->assertTrue($articleLoader->isSupported('articles'));
     $this->assertFalse($articleLoader->isSupported('items'));
     $article = $articleLoader->load('article', ['contentPath' => '/swp/content/test-article']);
     $this->assertInstanceOf('SWP\\TemplatesSystem\\Gimme\\Meta\\Meta', $article);
     $this->assertFalse($articleLoader->load('article', ['contentPath' => '/swp/content/test-articles']));
     $this->assertFalse($articleLoader->load('article', ['contentPath' => '/swp/content/test-article'], LoaderInterface::COLLECTION));
     $article = new Article();
     $article->setTitle('Features');
     $article->setContent('Features ipsum');
     $manager->persist($article);
     $manager->flush();
     $this->assertTrue(count($articleLoader->load('article', ['pageName' => 'News'], LoaderInterface::COLLECTION)) == 1);
     $this->assertFalse($articleLoader->load('article', ['pageName' => 'Features'], LoaderInterface::COLLECTION));
     $this->assertFalse($articleLoader->load('article', null, LoaderInterface::COLLECTION));
 }
コード例 #2
0
 public function testGenerateUrlFor()
 {
     $this->loadFixtureFiles(['@SWPFixturesBundle/DataFixtures/ORM/Test/page.yml', '@SWPFixturesBundle/DataFixtures/ORM/Test/pagecontent.yml']);
     $this->runCommand('doctrine:phpcr:init:dbal', ['--force' => true, '--env' => 'test'], true);
     $this->runCommand('doctrine:phpcr:repository:init', ['--env' => 'test'], true);
     $manager = $this->getContainer()->get('doctrine_phpcr.odm.document_manager');
     $article = new Article();
     $article->setTitle('Features');
     $article->setContent('Features ipsum');
     $manager->persist($article);
     $manager->flush();
     $this->assertTrue($article->getTitle() === 'Features');
     $contentExtension = new ContentExtension($this->getContainer()->get('doctrine'), $this->getContainer()->get('router'));
     $articleLoader = $this->getContainer()->get('swp_template_engine.loader.article');
     $featuresUrl = $contentExtension->gimmeUrl($articleLoader->load('article', ['contentPath' => '/swp/content/features']));
     $this->assertEquals('/news/features', $featuresUrl, 'Should generate url for Features article under News page: /news/features');
     $wrongObject = $contentExtension->gimmeUrl([]);
     $this->assertEquals(false, $wrongObject, 'Should return false when wrong object is passed');
     $wrongObject = $contentExtension->gimmeUrl(new Meta($this->getContainer()->getParameter('kernel.root_dir') . '/Resources/meta/article.yml', []));
     $this->assertEquals(false, $wrongObject, 'Should return false when meta with vrong values object is passed');
     $article = new Article();
     $article->setTitle('Contact');
     $article->setContent('Contact lipsum ');
     $manager->persist($article);
     $manager->flush();
     $wrongUrlType = $contentExtension->gimmeUrl($articleLoader->load('article', ['contentPath' => '/swp/content/contact']));
     $this->assertFalse($wrongUrlType, 'Should return false for not existing pageArticle');
     $article = new Article();
     $article->setTitle('Test Article');
     $article->setContent('Test Article lipsum ');
     $manager->persist($article);
     $manager->flush();
     $childPageUrl = $contentExtension->gimmeUrl($articleLoader->load('article', ['contentPath' => '/swp/content/test-article']));
     $this->assertEquals('/news/sport/test-article', $childPageUrl, 'Should generate url for Test Article article under Sport page with News as a parent page: /news/sport/test-article');
 }
コード例 #3
0
 public function testLoadingContainerPageArticle()
 {
     $manager = $this->getContainer()->get('doctrine_phpcr.odm.document_manager');
     $article = new Article();
     $article->setTitle('Features');
     $article->setContent('Features ipsum');
     $manager->persist($article);
     $manager->flush();
     $this->assertTrue($article->getTitle() === 'Features');
     $client = static::createClient();
     $crawler = $client->request('GET', '/news/features');
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
     $this->assertTrue($crawler->filter('html:contains("Features")')->count() === 1);
     $this->assertTrue($crawler->filter('html:contains("Features ipsum")')->count() === 1);
     $this->assertTrue($crawler->filter('html:contains("Id: /swp/content/features")')->count() === 1);
 }