Exemplo n.º 1
0
 private function get_recent_posts()
 {
     global $container;
     $postRepository = new MysqlPostRepository($container['db_connection_locator']);
     $recentPosts = $postRepository->getActivePosts(3);
     $recent_post_array = array();
     foreach ($recentPosts as $postResult) {
         $post = new stdclass();
         $post->title = $postResult['title'];
         $post->url = Loader::getRootUrl('blog') . "{$postResult['category']}/{$postResult['path']}/";
         $post->category = ucwords(str_replace('-', ' ', $postResult['category']));
         $post->thumb = Content::instance('FetchFirstPhoto', $postResult['body'])->activate();
         $post->body = Content::instance('SmartTrim', $postResult['body'])->activate($post->thumb !== '' ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
         $recent_post_array[] = $post;
     }
     return $recent_post_array;
 }
Exemplo n.º 2
0
 public function testGetActivePostsRangeFailure()
 {
     $testData = [['id' => rand(1, 100), 'display' => 1], ['id' => rand(101, 200), 'display' => 1], ['id' => rand(201, 300), 'display' => 1]];
     array_walk($testData, [$this, 'insertPostData']);
     $repository = new MysqlPostRepository(self::$connection);
     $data = $repository->getActivePosts(1, 3);
     $this->assertEmpty($data);
     $this->assertInternalType('array', $data);
 }