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)); }
/** * Список постов. * @return string */ public function actionIndex() { $post = new Post(); $category = new Category(); return $this->render('index', ['posts' => $post->getPublishedPosts(), 'categories' => $category->getCategories()]); }