public function testDropDownResolveValueAndSetToModelUpdateSteppingForwardAndBackward()
 {
     $form = new DropDownWorkflowActionAttributeForm('WorkflowsTestModule', 'WorkflowModelTestItem');
     $form->type = DropDownWorkflowActionAttributeForm::TYPE_DYNAMIC_STEP_FORWARD_OR_BACKWARDS;
     $form->value = '2';
     //Step forward where the new forward step is valid
     $model = new WorkflowModelTestItem();
     $model->dropDown->value = 'A1';
     $adapter = new WorkflowActionProcessingModelAdapter($model, Yii::app()->user->userModel);
     $form->resolveValueAndSetToModel($adapter, 'dropDown');
     $this->assertEquals('C3', $model->dropDown->value);
     //Step forward where the new forwardstep is invalid
     $model = new WorkflowModelTestItem();
     $model->dropDown->value = 'E5';
     $adapter = new WorkflowActionProcessingModelAdapter($model, Yii::app()->user->userModel);
     $form->resolveValueAndSetToModel($adapter, 'dropDown');
     $this->assertEquals('E5', $model->dropDown->value);
     //Step forward where the new backward step is valid
     $form->value = '-1';
     $model = new WorkflowModelTestItem();
     $model->dropDown->value = 'C3';
     $adapter = new WorkflowActionProcessingModelAdapter($model, Yii::app()->user->userModel);
     $form->resolveValueAndSetToModel($adapter, 'dropDown');
     $this->assertEquals('B2', $model->dropDown->value);
     //Step forward where the new backward step is invalid
     $form->value = '-1';
     $model = new WorkflowModelTestItem();
     $model->dropDown->value = 'A1';
     $adapter = new WorkflowActionProcessingModelAdapter($model, Yii::app()->user->userModel);
     $form->resolveValueAndSetToModel($adapter, 'dropDown');
     $this->assertEquals('A1', $model->dropDown->value);
 }
 public function testGetTypeValuesAndLabels()
 {
     $form = new CheckBoxWorkflowActionAttributeForm('WorkflowModelTestItem', 'boolean');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new CurrencyValueWorkflowActionAttributeForm('WorkflowModelTestItem', 'currencyValue');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new DateWorkflowActionAttributeForm('WorkflowModelTestItem', 'date');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(2, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(false, true);
     $this->assertEquals(3, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new DateTimeWorkflowActionAttributeForm('WorkflowModelTestItem', 'dateTime');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(2, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(false, true);
     $this->assertEquals(3, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new DecimalWorkflowActionAttributeForm('WorkflowModelTestItem', 'float');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new DropDownWorkflowActionAttributeForm('WorkflowModelTestItem', 'dropDowns');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(false, true);
     $this->assertEquals(2, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new EmailWorkflowActionAttributeForm('WorkflowModelTestItem', 'email');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, false);
     $this->assertEquals(2, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new IntegerWorkflowActionAttributeForm('WorkflowModelTestItem', 'integer');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new ContactStateWorkflowActionAttributeForm('WorkflowModelTestItem', 'likeContactState');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new MultiSelectDropDownWorkflowActionAttributeForm('WorkflowModelTestItem', 'multiDropDown');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new PhoneWorkflowActionAttributeForm('WorkflowModelTestItem', 'phone');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, false);
     $this->assertEquals(2, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new RadioDropDownWorkflowActionAttributeForm('WorkflowModelTestItem', 'radioDropDown');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(false, true);
     $this->assertEquals(2, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new TagCloudWorkflowActionAttributeForm('WorkflowModelTestItem', 'tagCloud');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new TextWorkflowActionAttributeForm('WorkflowModelTestItem', 'text');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, false);
     $this->assertEquals(2, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new TextAreaWorkflowActionAttributeForm('WorkflowModelTestItem', 'textArea');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, false);
     $this->assertEquals(2, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new UrlWorkflowActionAttributeForm('WorkflowModelTestItem', 'url');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(1, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, false);
     $this->assertEquals(2, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new UserWorkflowActionAttributeForm('WorkflowModelTestItem', 'user');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(2, count($valuesAndLabels));
     $valuesAndLabels = $form->getTypeValuesAndLabels(false, true);
     $this->assertEquals(4, count($valuesAndLabels));
     $this->assertTrue($form->resolveValueBeforeSave());
     $form = new ExplicitReadWriteModelPermissionsWorkflowActionAttributeForm('WorkflowModelTestItem', 'permissions');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(3, count($valuesAndLabels));
     $this->assertFalse($form->resolveValueBeforeSave());
     //Make new group and confirm it shows up
     $group = new Group();
     $group->name = 'test';
     $this->assertTrue($group->save());
     $form = new ExplicitReadWriteModelPermissionsWorkflowActionAttributeForm('WorkflowModelTestItem', 'permissions');
     $valuesAndLabels = $form->getTypeValuesAndLabels(true, true);
     $this->assertEquals(4, count($valuesAndLabels));
 }
 /**
  * @depends testDecimalWorkflowAttributeFormSetGetAndValidate
  */
 public function testDropDownWorkflowAttributeFormSetGetAndValidate()
 {
     $form = new DropDownWorkflowActionAttributeForm('WorkflowModelTestItem', 'dropDown');
     $form->type = WorkflowActionAttributeForm::TYPE_STATIC;
     $form->shouldSetValue = true;
     $form->value = 'Static 1';
     $validated = $form->validate();
     $this->assertTrue($validated);
     //Test invalid dropDown value
     $form->value = 123123;
     $validated = $form->validate();
     $this->assertFalse($validated);
     //test valid date, but not correct format for dynamic type
     $form->type = DropDownWorkflowActionAttributeForm::TYPE_DYNAMIC_STEP_FORWARD_OR_BACKWARDS;
     $form->value = 'Static 1';
     $validated = $form->validate();
     $this->assertFalse($validated);
     //Test valid date and valid format for dynamic type
     $form->value = -8600;
     $validated = $form->validate();
     $this->assertTrue($validated);
     $form->value = 3000;
     $validated = $form->validate();
     $this->assertTrue($validated);
 }