예제 #1
0
 public function testGetCollectionForItems()
 {
     $cm = new CollectionManager();
     $cm->addCollection(new Collection('events', '_events', ['output' => true]));
     $cm->addCollection(new Collection('books', '_books', ['output' => true]));
     $cm->setCollection(new Collection('posts', '_posts', ['output' => true]));
     $this->assertEquals(4, $cm->countCollection());
     $item = new Item('Test of content', '_events/event-1.html', []);
     $item->setPath('_events/event-1.html', Item::SNAPSHOT_PATH_RELATIVE);
     $collection = $cm->getCollectionForItem($item);
     $this->assertInstanceOf('\\Yosymfony\\Spress\\Core\\ContentManager\\Collection\\CollectionInterface', $collection);
     $this->assertEquals('events', $collection->getName());
     $this->assertEquals('_events', $collection->getPath());
     $this->assertCount(1, $collection->getAttributes());
     $item = new Item('Test of content', '_books/symfony-book.html', []);
     $item->setPath('_books/symfony-book.html', Item::SNAPSHOT_PATH_RELATIVE);
     $collection = $cm->getCollectionForItem($item);
     $this->assertEquals('books', $collection->getName());
 }