/** * @test */ public function create() { $model = new WebPage(); $model->attributes = array('title' => 'test', 'name' => "test", 'description' => "description test", 'keywords' => "test"); $this->assertTrue($model->save()); $model = new WebPage(); $model->attributes = array('title' => 'testa', 'name' => "test"); $this->assertFalse($model->save()); $this->assertInstanceOf('WebPage', WebPage::model()); }
/** * Renvoie la page de code $pageName. * @param string $pageName * @return WebPage|null * @internal utiliser de préférence la méthode BaseController::getPage() qui encapsule cet appel */ public static function getByName($pageName) { return WebPage::model()->findByAttributes(array('name' => $pageName)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return WebPage the loaded model * @throws CHttpException */ public function loadModel($id) { $model = WebPage::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }