コード例 #1
0
ファイル: PostTest.php プロジェクト: richardcj/Blog-Yii2
 public function testGetPublishedPosts()
 {
     $posts = $this->postModel->getPublishedPosts();
     $this->assertInstanceOf('yii\\data\\ActiveDataProvider', $posts);
     $count = $this->postModel->findAll(['publish_status' => Post::STATUS_PUBLISH]);
     $this->assertEquals($posts->count, count($count));
 }
コード例 #2
0
 /**
  * Список постов.
  * @return string
  */
 public function actionIndex()
 {
     $post = new Post();
     $category = new Category();
     return $this->render('index', ['posts' => $post->getPublishedPosts(), 'categories' => $category->getCategories()]);
 }