setTags() public method

public setTags ( $tags )
Example #1
0
 public function testOnDocuments()
 {
     $documents = array();
     for ($i = 1; $i <= 20; ++$i) {
         $document = new Document(null, null, Document::TYPE_POST);
         $document->setTitle('Post #' . $i);
         $document->setTags('Tag #' . $i % 5);
         $documents[] = $document;
     }
     for ($i = 1; $i <= 20; ++$i) {
         $document = new Document(null, null, Document::TYPE_PAGE);
         $document->setTitle('Post #' . $i);
         $document->setTags('Tag #' . $i % 5);
         $documents[] = $document;
     }
     $processor = new Processor();
     $globals = $processor->processGlobals($documents);
     $event = new CarewEvent($documents, array('globals' => $globals));
     $tagFeed = new TagsFeed();
     $tagFeed->onDocuments($event);
     $documents = $event->getSubject();
     // 20 posts, 20 pages, 5 tags index
     $this->assertCount(45, $documents);
     $this->assertSame('tags/tag-1/feed/atom.xml', $documents['tags/Tag #1/feed/atom']->getPath());
 }
Example #2
0
 public function testOnDocuments()
 {
     $tags = new Tags();
     $documents = array();
     for ($i = 1; $i <= 20; ++$i) {
         $document = new Document();
         $document->setTitle('Post #' . $i);
         $document->setTags('Tag #' . $i % 5);
         $documents[] = $document;
     }
     $processor = new Processor();
     $globals = $processor->processGlobals($documents);
     $event = new CarewEvent($documents, array('globals' => $globals));
     $tags->onDocuments($event);
     $documents = $event->getSubject();
     // 20 post, 1 page for all tags, 5 tags
     $this->assertCount(26, $documents);
     $this->assertSame('tags/tag-1.html', $documents['tags/Tag #1']->getPath());
 }
Example #3
0
 public function setUp()
 {
     $this->container = new \Pimple();
     $this->extension = new CarewExtension($this->container);
     $this->twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array(__DIR__ . '/fixtures/theme1', __DIR__ . '/fixtures/theme2', __DIR__ . '/../../Twig/Resources/layouts')));
     $documents = array();
     for ($i = 1; $i <= 20; ++$i) {
         $document = new Document();
         $document->setTitle('Doc #' . $i);
         $document->setTags('Tag #' . $i % 5);
         $document->setFilePath('pages/page-' . $i);
         $document->setPath('pages/page-' . $i . '.html');
         $documents[$document->getFilePath()] = $document;
     }
     $processor = new Processor();
     $this->globals = $processor->processGlobals($documents);
     $this->documents = $documents;
     $this->twig->addGlobal('carew', $this->globals);
     $this->twig->addExtension($this->extension);
 }