/** * @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()); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new WebPage(); if (isset($_POST['WebPage'])) { $model->attributes = $_POST['WebPage']; if ($model->save()) { Yii::app()->user->setFlash('success', Yii::t('WebPagesModule.msg', 'The page has been created. You can now add texts')); if (isset($_POST['backToList'])) { // On a cliqué le bouton 'revenir à la liste' et le formulaire a bien été traité Yii::app()->session->add('admin_reloadFilters', 1); $this->redirect(array('admin')); } else { $this->redirect(array('update', 'id' => $model->id)); } } else { Yii::app()->user->setFlash('error', Yii::t('msg', 'There are errors. Please check the form')); } } /** @noinspection PhpUndefinedMethodInspection */ $this->render('create', array('model' => $model, 'languages' => $this->languages)); }
public function test_should_destroy_record() { $WebPage = new WebPage(array('body' => 'Akelos PHP framework')); $WebPage->save(); $WebPage2 = new WebPage($WebPage->getId()); $this->assertEqual($WebPage->body, $WebPage2->body); $WebPage2->destroy(); $WebPage2 = new WebPage($WebPage->getId()); $this->assertTrue($WebPage2->isNewRecord()); $this->assertFalse($WebPage->find($WebPage->getId())); }