/** * Finds the Media model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param string $media_slug * * @return Media the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModelBySlug($media_slug) { if (($model = Media::findOne(['media_slug' => $media_slug])) !== null) { return $model; } throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.')); }
/** * Finds the Media model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * * @return Media the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Media::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @param AcceptanceTester $I */ public function testUpdate(AcceptanceTester $I) { $I->wantTo('ensure that update page works'); $updatePage = UpdatePage::openBy($I); $I->see('Update Media', 'h1'); $I->amGoingTo('submit update media form'); $updatePage->submit(['title' => 'test123', 'excerpt' => 'TEST QWERT']); $I->expect('media updated'); Media::findOne(1)->updateAttributes(['title' => 'Test Media', 'excerpt' => 'Test Media Caption']); }
/** * @param FunctionalTester $I */ public function testProtected(FunctionalTester $I) { Media::findOne(1)->updateAttributes(['password' => 'mediapassword']); $I->wantTo('ensure that protected media works'); $mediaView = MediaViewPage::openBy($I); $I->see('Test Media', 'h1'); $I->amGoingTo('submit password form with incorrect password'); $mediaView->submitPassword('wrong_password'); $I->expectTo('not see the media'); $I->dontSeeElement('.entry-meta'); $I->amGoingTo('submit password form with correct password'); $mediaView->submitPassword('mediapassword'); $I->expectTo('see the post'); $I->seeElement('.entry-meta'); $I->seeLink('Test Media'); Media::findOne(1)->updateAttributes(['password' => '']); }
/** * Finds the Media model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * * @return Media the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findMedia($id) { if (($model = Media::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.')); }
/** * @param AcceptanceTester $I */ public function testComment(AcceptanceTester $I) { $I->wantTo('ensure that media comment works'); $mediaView = MediaViewPage::openBy($I); // $I->see('Test Media', 'h1'); $I->see('Test Media'); $I->amGoingTo('submit media comment form with no data'); $mediaView->submitComment([]); $I->expectTo('see validations error'); $I->see('Name cannot be blank.', '.help-block'); $I->see('Email cannot be blank.', '.help-block'); $I->see('Content cannot be blank.', '.help-block'); $I->amGoingTo('submit media comment form with no correct email'); $mediaView->submitComment(['comment_author' => 'tester', 'comment_author_email' => 'tester.email', 'comment_content' => 'New comment']); $I->expectTo('see that email is not correct'); $I->see('Email is not a valid email address.'); $I->dontSee('Name cannot be blank.', '.help-block'); $I->dontSee('Content cannot be blank.', '.help-block'); $I->amGoingTo('submit media comment form with correct data'); $mediaView->submitComment(['comment_author' => 'tester', 'comment_author_email' => '*****@*****.**', 'comment_content' => 'New comment']); $I->expect('new comment saved'); $I->dontSee('Name cannot be blank.', '.help-block'); $I->dontSee('Email cannot be blank.', '.help-block'); $I->dontSee('Content cannot be blank.', '.help-block'); MediaComment::deleteAll(['comment_author' => 'tester']); Media::findOne(1)->updateAttributes(['media_comment_count' => '1']); }
public function actionDelete() { $media = Media::findOne(['id' => $_GET['id']]); $media->delete(); $this->redirect('media'); }
/** * Finds the Media model based on its primary key value. * If the model is not found it will return null. * * @param integer $id * * @return Media|array */ protected function findMedia($id) { if (($model = Media::findOne($id)) !== null) { return $model; } else { return null; } }