/** * Finds the Post model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param $postType * * @throws \yii\web\NotFoundHttpException * @return PostType the loaded model */ protected function findPostTypeBySlug($postType) { $model = PostType::findOne(['post_type_slug' => $postType]); if ($model) { return $model; } throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.')); }
/** * Finds the PostType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * * @return PostType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findPostType($id) { if (($model = PostType::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException('The requested page does not exist.'); }
/** * @param FunctionalTester $I */ public function testUpdate(FunctionalTester $I) { $I->wantTo('ensure that create post-type works'); $updatePage = UpdatePage::openBy($I); $I->see('Update Post Type: Post', 'h1'); $I->amGoingTo('submit post-type form with correct data'); $I->checkOption('#posttype-post_type_smb'); $I->selectOption('#posttype-post_type_permission', 'subscriber'); $updatePage->submitPostType(['post_type_description' => 'New post-type description']); $I->expectTo('post-type updated'); // $I->see('View Post Type: Post', 'h1'); $I->see('View Post Type: Post'); PostType::findOne(1)->update(['post_type_smb' => '0', 'post_type_permission' => 'contributor', 'post_type_description' => '']); Taxonomy::deleteAll(['taxonomy_name' => 'test-taxonomy']); }
/** * Finds the PostType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * @return PostType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = PostType::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.')); }
/** * @param AcceptanceTester $I */ public function testUpdate(AcceptanceTester $I) { $I->wantTo('ensure that create post-type works'); $updatePage = UpdatePage::openBy($I); $I->see('Update Post Type: Post', 'h1'); // Only run for selenium if (method_exists($I, 'executeJS')) { $I->amGoingTo('submit taxonomy with no data'); $updatePage->submitTaxonomy([]); $I->expectTo('see validation errors'); $I->see('Name cannot be blank.', '.help-block'); $I->see('Singular Name cannot be blank.', '.help-block'); $I->see('Plural Name cannot be blank.', '.help-block'); $I->amGoingTo('submit taxonomy with correct data'); $updatePage->submitTaxonomy(['taxonomy_name' => 'test-taxonomy', 'taxonomy_sn' => 'Test Taxonomy', 'taxonomy_pn' => 'Test Taxonomies']); $I->expect('new taxonomy saved'); $I->see('test-taxonomy', '#taxonomy_list'); $I->dontSee('Name cannot be blank.', '.help-block'); $I->dontSee('Singular Name cannot be blank.', '.help-block'); $I->dontSee('Plural Name cannot be blank.', '.help-block'); } // Test update data $I->amGoingTo('submit post-type form with correct data'); $I->checkOption('#posttype-post_type_smb'); $I->selectOption('#posttype-post_type_permission', 'subscriber'); $updatePage->submitPostType(['post_type_description' => 'New post-type description']); $I->expectTo('post-type updated'); $I->see('View Post Type: Post', 'h1'); PostType::findOne(1)->update(['post_type_smb' => '0', 'post_type_permission' => 'contributor', 'post_type_description' => '']); Taxonomy::deleteAll(['taxonomy_name' => 'test-taxonomy']); }
/** * Finds the Post model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param $id * * @throws \yii\web\NotFoundHttpException * @return PostType the loaded model */ protected function findPostType($id) { $model = PostType::findOne($id); if ($model) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }