コード例 #1
0
 /**
  * @dataProvider getOutputPathDataProvider
  */
 public function testGetOutputPath($uri, $pageNumber, $prettyUrls, $expectedPath, $singlePage = false)
 {
     $app = new MockPieCrust();
     $page = new MockPage($app);
     $page->uri = $uri;
     $page->pageNumber = $pageNumber;
     if ($prettyUrls) {
         $page->getConfig()->setValue('pretty_urls', true);
     }
     if ($singlePage) {
         $page->getConfig()->setValue('single_page', true);
     }
     $baker = new PageBaker('/tmp');
     $path = $baker->getOutputPath($page);
     $expectedPath = '/tmp/' . $expectedPath;
     $this->assertEquals($expectedPath, $path);
 }
コード例 #2
0
ファイル: PaginatorTest.php プロジェクト: giftnuss/PieCrust
 /**
  * @dataProvider categoryPageDataProvider
  */
 public function testCategoryPage($pageConfig, $categorize, $tagging, $expectedIndices)
 {
     $pc = new MockPieCrust();
     $page = new MockPage($pc);
     $page->pageType = IPage::TYPE_CATEGORY;
     $page->pageKey = 'foo';
     foreach ($pageConfig as $key => $value) {
         $page->getConfig()->setValue($key, $value);
     }
     $posts = $this->buildPaginationDataSource($pc, 10);
     // The pagination data source is ordered in reverse
     // chronological order. Let's reverse it to be able
     // to index posts easily.
     // (the Paginator will reorder them internally)
     $posts = array_reverse($posts);
     foreach ($categorize as $i => $category) {
         $posts[$i]->getConfig()->setValue('category', $category);
     }
     foreach ($tagging as $i => $tags) {
         $posts[$i]->getConfig()->setValue('tags', $tags);
     }
     $paginator = new Paginator($page);
     $paginator->setPaginationDataSource($posts);
     $this->assertExpectedPostsData($expectedIndices, $paginator->posts());
 }