/** * testing method return array type */ public function testTypeFunction() { $model = new QuestionBloc(); $criteria = new EMongoCriteria(); $criteria->title = "Renseignements individuels"; $questionBloc = QuestionBloc::model()->find($criteria); $this->assertInternalType('array', $model->rules()); $this->assertInternalType('array', $model->attributeLabels()); $this->assertInternalType('object', $model->search()); $this->assertInternalType('array', $model->getBlocsByTitle($questionBloc->title)); $this->assertInternalType('array', $model->getAllBlocsTitles()); $this->assertInternalType('array', $model->getAllTitlesBlocs()); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new QuestionBloc(); if (isset($_POST['QuestionBloc'])) { $model->attributes = $_POST['QuestionBloc']; $model->title_fr = $model->title; $countBloc = $model->getBlocsByTitle($model->title_fr); if (count($countBloc) > 0) { Yii::app()->user->setFlash('error', Yii::t('common', 'titleExist')); } elseif ($model->save()) { Yii::app()->user->setFlash('success', Yii::t('common', 'questionBlockSaved')); $this->redirect($this->createUrl('update', array('id' => $model->_id))); } else { Yii::app()->user->setFlash('error', Yii::t('common', 'missingFields')); } } $this->render('create', array('model' => $model)); }