Beispiel #1
0
 /**
  * @noCall
  * @include
  * @documentation The list of all posts for this blog.
  */
 public function posts()
 {
     $blogPosts = PageHelper::getPosts($this->page->getApp(), $this->blogKey);
     $posts = new PageIterator($this->page->getApp(), $this->blogKey, $blogPosts);
     $posts->setCurrentPage($this->page);
     return $posts;
 }
Beispiel #2
0
 /**
  * @dataProvider sortedPaginationDataProvider
  */
 public function testSortedPagination($sortByName, $configSetter, $expectedIndices, $sortByReverse = false)
 {
     $pc = new MockPieCrust();
     $posts = array();
     for ($i = 0; $i < 10; ++$i) {
         $year = 2012;
         $month = 1;
         $day = $i;
         $name = "test-post-number-{$i}-name";
         $path = "test-post-number-{$i}-path.html";
         $dummyPage = new MockPage($pc);
         $dummyPage->uri = $name;
         $dummyPage->path = $path;
         $dummyPage->date = mktime(0, 0, 0, $month, $day, $year);
         if ($sortByName && $configSetter) {
             $dummyPage->config->setValue($sortByName, $configSetter($i));
         }
         $dummyPage->contents = array('content' => "Test page {$i} contents.");
         $posts[] = $dummyPage;
     }
     $it = new PageIterator($pc, 'blog', $posts);
     if ($sortByName) {
         $it->sortBy($sortByName, $sortByReverse);
     }
     $this->assertEquals(count($expectedIndices), count($it));
     foreach ($expectedIndices as $k => $i) {
         $post = $it[$k];
         $this->assertEquals("test-post-number-{$i}-name", $post['slug']);
         $this->assertEquals("Test page {$i} contents.", $post['content']);
     }
 }