/** * @covers Gacela\Field\Time::validate * @dataProvider providerNull */ public function testValidateNull($meta, $value, $in) { $this->assertEquals(Time::NULL_CODE, $this->object->validate($meta, $value)); }
/** * Generated from @assert (NULL) === false. * * @covers pgn\tags\Time::validate */ public function testValidate14() { $this->assertSame(false, $this->object->validate(NULL)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'show' page. */ public function actionCreate() { $model = new Time($this->action->id); if (isset($_POST['Time'])) { // collect user input data $model->attributes = $_POST['Time']; if (!isset($_POST['Time']['managerId'])) { // set manager based on the task if ($model->taskId >= 1) { $criteria = new CDbCriteria(); $criteria->order = "`t`.`userPriority` ASC, `t`.`id` ASC"; if (($user2Task = User2Task::model()->findByAttributes(array('taskId' => $model->taskId, 'role' => User2Task::MANAGER), $criteria)) !== null) { $model->managerId = $user2Task->userId; } else { $model->managerId = 0; } } else { $model->managerId = 0; } } if (!isset($_POST['Time']['consultantId'])) { // set consultant based on the task if ($model->taskId >= 1) { $criteria = new CDbCriteria(); $criteria->order = "`t`.`userPriority` ASC, `t`.`id` ASC"; if (($user2Task = User2Task::model()->findByAttributes(array('taskId' => $model->taskId, 'role' => User2Task::CONSULTANT), $criteria)) !== null) { $model->consultantId = $user2Task->userId; } else { $model->consultantId = 0; } } else { $model->consultantId = 0; } } // validate with the current action as scenario and save without validation if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) { // set success message MUserFlash::setTopSuccess(Yii::t('hint', 'The new "{title}" time record has been successfully created.', array('{title}' => MHtml::wrapInTag($model->title, 'strong')))); // go to the 'show' page $this->redirect(array('show', 'id' => $model->id)); } } else { // pre-assigned attributes (default values for a new record) if (Yii::app()->user->checkAccess(User::MANAGER) || Yii::app()->user->checkAccess(User::ADMINISTRATOR)) { $model->isConfirmed = Time::IS_CONFIRMED; } if (isset($_GET['taskId'])) { // task is known $model->taskId = $_GET['taskId']; } } $this->render($this->action->id, array('model' => $model)); }