Пример #1
0
 public function testIsFieldUsedInTransitions()
 {
     $field_start_date = new MockTracker_FormElement_Field_Date($this);
     $field_start_date->setReturnValue('getId', 1002);
     $field_close_date = new MockTracker_FormElement_Field_Date($this);
     $field_close_date->setReturnValue('getId', 1003);
     $tpaf = new MockTransition_PostActionFactory();
     $tpaf->setReturnValue('isFieldUsedInPostActions', false, array($field_start_date));
     $tpaf->setReturnValue('isFieldUsedInPostActions', true, array($field_close_date));
     $tf = TestHelper::getPartialMock('TransitionFactory', array('getPostActionFactory'));
     $tf->setReturnReference('getPostActionFactory', $tpaf);
     $this->assertFalse($tf->isFieldUsedInTransitions($field_start_date));
     $this->assertTrue($tf->isFieldUsedInTransitions($field_close_date));
 }
 public function testDisplayDiffShouldNotStripHtmlTagsInPlainTextFormat()
 {
     $diff = "@@ -1 +1 @@\n- Quelle est la couleur <b> du <i> cheval blanc d'Henri IV?\n+ Quelle est la couleur <b> du <i> <s> cheval blanc d'Henri IV?";
     $format = 'text';
     $field = new MockTracker_FormElement_Field_Date();
     $field->setReturnValue('getLabel', 'Summary');
     $changeset = new Tracker_Artifact_Changeset(null, null, null, null, null);
     $result = $changeset->displayDiff($diff, $format, $field);
     $this->assertPattern('%Quelle est la couleur <b> du <i> <s> cheval blanc%', $result);
     $this->assertPattern('%Summary%', $result);
 }
 public function testBeforeShouldNOTDisplayFeedback()
 {
     $current_user = new MockUser();
     $field = new MockTracker_FormElement_Field_Date();
     $field->setReturnValue('getId', 102);
     $field->setReturnValue('getLabel', 'Close Date');
     $field->setReturnValue('userCanRead', false, array($current_user));
     $factory = new MockTracker_FormElementFactory();
     $factory->setReturnReference('getFormElementById', $field, array($field->getId()));
     $expected = $field->formatDate($_SERVER['REQUEST_TIME']);
     $transition = new MockTransition();
     $field_id = $field->getId();
     $id = 1;
     $fields_data = array('field_id' => 'value');
     $value_type = Transition_PostAction_Field_Date::CLEAR_DATE;
     $post_action = new Transition_PostAction_Field_DateTestVersion();
     $post_action->expectNever('addFeedback');
     $post_action->setReturnReference('getFormElementFactory', $factory);
     $post_action->__construct($transition, $id, $field, $value_type);
     $post_action->before($fields_data, $current_user);
     $this->assertEqual($expected, $fields_data[$field_id]);
 }