Exemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     $this->user = mock('PFUser');
     $this->user->setReturnValue('getId', 666);
     $this->artifact = new MockTracker_Artifact($this);
     $af = new MockTracker_ArtifactFactory($this);
     $af->setReturnReference('getArtifactById', $this->artifact, array('1'));
     $this->report = new MockTracker_Report($this);
     $rf = new MockTracker_ReportFactory($this);
     $rf->setReturnReference('getReportById', $this->report, array('2', $this->user->getId(), true));
     $this->tracker = new MockTracker($this);
     $this->tracker->setReturnValue('isActive', true);
     $this->tracker->setReturnValue('userCanView', true);
     $tf = new MockTrackerFactory($this);
     $tf->setReturnReference('getTrackerById', $this->tracker, array(3));
     $this->formElement = new MockTracker_FormElement_Interface($this);
     $ff = new MockTracker_FormElementFactory($this);
     $ff->setReturnReference('getFormElementById', $this->formElement, array('4'));
     $this->artifact->setReturnReference('getTracker', $this->tracker);
     $this->report->setReturnReference('getTracker', $this->tracker);
     $this->formElement->setReturnReference('getTracker', $this->tracker);
     $this->url = new Tracker_URLTestVersion($this);
     $this->url->setReturnReference('getTrackerFactory', $tf);
     $this->url->setReturnReference('getTracker_FormElementFactory', $ff);
     $this->url->setReturnReference('getArtifactFactory', $af);
     $this->url->setReturnReference('getArtifactReportFactory', $rf);
 }
 public function testImportFormElement()
 {
     $xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?>
         <formElement type="mon_type" ID="F0" rank="20" required="1">
             <name>field_name</name>
             <label>field_label</label>
             <description>field_description</description>
             <formElements>
                 <formElement type="date" ID="F1" rank="1" required="1">
                     <name>date</name>
                     <label>date</label>
                     <description>date</description>
                 </formElement>
             </formElements>
         </formElement>');
     $mapping = array();
     $a_formelement = new MockTracker_FormElement_Field_Date();
     $factory = new MockTracker_FormElementFactory();
     $factory->setReturnReference('getInstanceFromXML', $a_formelement);
     $f = new Tracker_FormElement_Container_FieldsetTestVersion();
     $f->setTracker(aTracker()->withProject(mock('Project'))->build());
     $f->setReturnReference('getFormElementFactory', $factory);
     $f->continueGetInstanceFromXML($xml, $mapping);
     $container_should_load_child = array($a_formelement);
     $this->assertEqual($f->getFormElements(), $container_should_load_child);
 }
Exemplo n.º 3
0
 public function setUp()
 {
     parent::setUp();
     $this->user = new MockUser($this);
     $this->user->setReturnValue('getId', 666);
     $this->url = new MockTracker_URL();
     $project = new MockProject();
     $this->artifact = new MockTracker_Artifact($this);
     $af = new MockTracker_ArtifactFactory($this);
     $af->setReturnReference('getArtifactById', $this->artifact, array('1'));
     $this->report = new MockTracker_Report($this);
     $rf = new MockTracker_ReportFactory($this);
     $rf->setReturnReference('getReportById', $this->report, array('2', $this->user->getId(), true));
     $this->tracker = new MockTracker($this);
     $this->tracker->setReturnValue('isActive', true);
     $this->tracker->setReturnValue('getTracker', $this->tracker);
     $tf = new MockTrackerFactory($this);
     $tf->setReturnReference('getTrackerById', $this->tracker, array(3));
     $this->formElement = new MockTracker_FormElement_Interface($this);
     $ff = new MockTracker_FormElementFactory($this);
     $ff->setReturnReference('getFormElementById', $this->formElement, array('4'));
     $this->artifact->setReturnReference('getTracker', $this->tracker);
     $this->report->setReturnReference('getTracker', $this->tracker);
     $this->formElement->setReturnReference('getTracker', $this->tracker);
     $this->tracker->setReturnValue('getGroupId', 5);
     $this->tracker->setReturnReference('getProject', $project);
     $this->tm = new TrackerManagerTestVersion($this);
     $this->tm->setReturnReference('getUrl', $this->url);
     $this->tm->setReturnReference('getTrackerFactory', $tf);
     $this->tm->setReturnReference('getTracker_FormElementFactory', $ff);
     $this->tm->setReturnReference('getArtifactFactory', $af);
     $this->tm->setReturnReference('getArtifactReportFactory', $rf);
     $this->tm->setReturnValue('checkServiceEnabled', true);
     $GLOBALS['HTML'] = new MockLayout();
 }
Exemplo n.º 4
0
 public function testDisplayUpdateFormShouldDisplayAForm()
 {
     $formElement = $this->GivenAFormElementWithIdAndOriginalField(null, null);
     $factory = new MockTracker_FormElementFactory();
     $factory->setReturnValue('getUsedFormElementForTracker', array());
     $formElement->setTracker(new MockTracker());
     $formElement->setFormElementFactory($factory);
     $content = $this->WhenIDisplayAdminFormElement($formElement);
     $this->assertPattern('%Update%', $content);
     $this->assertPattern('%</form>%', $content);
 }
Exemplo n.º 5
0
 public function itReturnsTheArtifactLinkOfTheTracker()
 {
     $form_element_factory = new MockTracker_FormElementFactory();
     $art_link_release_field_id = 135;
     $artifact_link_field_of_release_tracker = new MockTracker_FormElement_Field_ArtifactLink();
     $artifact_link_field_of_release_tracker->setReturnValue('getId', $art_link_release_field_id);
     $form_element_factory->setReturnValue('getUsedArtifactLinkFields', array($artifact_link_field_of_release_tracker), array($this->tracker));
     $artifact_report_field = new Tracker_CrossSearch_ArtifactReportField($this->tracker, array());
     $database_field_key = $artifact_report_field->getArtifactLinkFieldName($form_element_factory);
     $this->assertEqual($database_field_key, 'art_link_' . $art_link_release_field_id);
 }
Exemplo n.º 6
0
 function testCreateNewChangesetWithoutNotification()
 {
     $email = null;
     //not anonymous user
     $comment = '';
     $this->response->expectCallCount('addFeedback', 0);
     $comment_dao = new MockTracker_Artifact_Changeset_CommentDao();
     stub($comment_dao)->createNewVersion()->returns(true);
     $comment_dao->expectCallCount('createNewVersion', 1);
     $dao = new MockTracker_Artifact_ChangesetDao();
     $dao->setReturnValueAt(0, 'create', 1001, array(66, 1234, null, $_SERVER['REQUEST_TIME']));
     $dao->setReturnValueAt(1, 'create', 1002, array(66, 1234, null, $_SERVER['REQUEST_TIME']));
     $dao->expectCallCount('create', 1);
     $user = mock('PFUser');
     $user->setReturnValue('getId', 1234);
     $user->setReturnValue('isAnonymous', false);
     $tracker = new MockTracker();
     $tracker->setReturnValue('getGroupId', 666);
     $tracker->setReturnValue('getItemName', 'foobar');
     $tracker->setReturnValue('getFormElements', array());
     $factory = new MockTracker_FormElementFactory();
     $field1 = new MockTracker_FormElement_Field();
     $field1->setReturnValue('getId', 101);
     $field1->setReturnValue('isValid', true);
     $field1->setReturnValue('isValidRegardingRequiredProperty', true);
     $field1->setReturnValue('userCanUpdate', true);
     $field1->setReturnValue('saveNewChangeset', true);
     $field1->expectOnce('saveNewChangeset');
     $field2 = new MockTracker_FormElement_Field();
     $field2->setReturnValue('getId', 102);
     $field2->setReturnValue('isValid', true, array('*', '123'));
     $field2->setReturnValue('isValid', false, array('*', '456'));
     $field2->setReturnValue('isValidRegardingRequiredProperty', true);
     $field2->setReturnValue('userCanUpdate', true);
     $field2->setReturnValue('saveNewChangeset', true);
     $field2->expectOnce('saveNewChangeset');
     $field3 = new MockTracker_FormElement_Field();
     $field3->setReturnValue('getId', 103);
     $field3->setReturnValue('isValid', true);
     $field3->setReturnValue('isValidRegardingRequiredProperty', true);
     $field3->setReturnValue('saveNewChangeset', true);
     $field3->expectOnce('saveNewChangeset');
     $field3->setReturnValue('userCanUpdate', true);
     $factory->setReturnValue('getUsedFields', array($field1, $field2, $field3));
     $factory->setReturnValue('getAllFormElementsForTracker', array());
     $new_changeset = new MockTracker_Artifact_Changeset();
     $new_changeset->expectNever('notify', array());
     $changeset = new MockTracker_Artifact_Changeset();
     $changeset->setReturnValue('hasChanges', true);
     $changeset_value1 = new MockTracker_Artifact_ChangesetValue();
     $changeset_value2 = new MockTracker_Artifact_ChangesetValue();
     $changeset_value3 = new MockTracker_Artifact_ChangesetValue();
     $changeset->setReturnReference('getValue', $changeset_value1, array($field1));
     $changeset->setReturnReference('getValue', $changeset_value2, array($field2));
     $changeset->setReturnReference('getValue', $changeset_value3, array($field3));
     $changeset->setReturnValue('getValues', array());
     $reference_manager = new MockReferenceManager();
     $reference_manager->expect('extractCrossRef', array($comment, 66, 'plugin_tracker_artifact', 666, $user->getId(), 'foobar'));
     $art_factory = new MockTracker_ArtifactFactory();
     $artifact = new Tracker_ArtifactTestVersion();
     $artifact->setReturnReference('getChangesetDao', $dao);
     $artifact->setReturnReference('getChangesetCommentDao', $comment_dao);
     $artifact->setReturnReference('getFormElementFactory', $factory);
     $artifact->setReturnReference('getTracker', $tracker);
     $artifact->setReturnValue('getId', 66);
     $artifact->setReturnReference('getLastChangeset', $changeset);
     $artifact->setReturnReference('getChangeset', $new_changeset);
     $artifact->setReturnReference('getReferenceManager', $reference_manager);
     $artifact->setReturnReference('getArtifactFactory', $art_factory);
     stub($art_factory)->save()->returns(true);
     $art_factory->expectOnce('save');
     $workflow = new MockWorkflow();
     $workflow->expectCallCount('before', 2);
     $workflow->setReturnValue('validate', true);
     $artifact->setReturnValue('getWorkflow', $workflow);
     // Valid
     $fields_data = array(102 => '123');
     $artifact->createNewChangeset($fields_data, $comment, $user, false);
     // Not valid
     $fields_data = array(102 => '456');
     $this->expectException('Tracker_Exception');
     $artifact->createNewChangeset($fields_data, $comment, $user);
 }
 public function itCleansUserFromRecipientsWhenUserCantReadAtLeastOneChangedField()
 {
     $field1 = new MockTracker_FormElement_Field_Date();
     $value1_previous = new MockTracker_Artifact_ChangesetValue_Date();
     $value1_current = new MockTracker_Artifact_ChangesetValue_Date();
     $dao = new MockTracker_Artifact_Changeset_ValueDao();
     $dar = new MockDataAccessResult();
     $fact = new MockTracker_FormElementFactory();
     $artifact = new MockTracker_Artifact();
     $previous_changeset = new MockTracker_Artifact_Changeset();
     $um = new MockUserManager();
     $comment = new MockTracker_Artifact_Changeset_Comment();
     $current_changeset = new Tracker_Artifact_ChangesetTestVersion();
     $previous_changeset->setReturnValue('getId', 65);
     $previous_changeset->setReturnReference('getValue', $value1_previous, array($field1));
     $previous_changeset->setReturnReference('getUserManager', $um);
     $artifact->setReturnReference('getPreviousChangeset', $previous_changeset, array(66));
     $dar->setReturnValueAt(0, 'current', array('changeset_id' => 66, 'field_id' => 1, 'id' => 11, 'has_changed' => 1));
     $dar->setReturnValue('valid', true);
     $dar->setReturnValueAt(2, 'valid', false);
     $dao->setReturnReference('searchById', $dar);
     $fact->setReturnReference('getFieldById', $field1, array(1));
     $field1->setReturnValue('getId', 1);
     $field1->setReturnValue('getLabel', 'field1');
     $field1->setReturnValue('userCanRead', false);
     $field1->setReturnReference('getChangesetValue', $value1_current, array('*', 11, 1));
     $value1_previous->expectNever('hasChanged');
     $value1_current->setReturnValue('hasChanged', true);
     $value1_current->setReturnValue('diff', 'has changed', array($value1_previous, '*'));
     $comment->setReturnValue('hasEmptyBody', true);
     $current_changeset->setReturnValue('getId', 66);
     $current_changeset->setReturnReference('getValueDao', $dao);
     $current_changeset->setReturnReference('getFormElementFactory', $fact);
     $current_changeset->setReturnReference('getArtifact', $artifact);
     $current_changeset->setReturnReference('getUserManager', $um);
     $current_changeset->setReturnReference('getComment', $comment);
     $recipients = array("recipient1" => true, "recipient2" => true, "recipient3" => true);
     $user1 = stub('PFUser')->getUserName()->returns('recipient1');
     $user2 = stub('PFUser')->getUserName()->returns('recipient2');
     $user3 = stub('PFUser')->getUserName()->returns('recipient3');
     $um->setReturnReference('getUserByUserName', $user1);
     $um->setReturnReference('getUserByUserName', $user2);
     $um->setReturnReference('getUserByUserName', $user3);
     $current_changeset->removeRecipientsThatMayReceiveAnEmptyNotification($recipients);
     $this->assertEqual($recipients, array());
 }
 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]);
 }
    function testNotify()
    {
        $defs = array(array('has_changed' => 1, 'isNotificationsSupported' => 1, 'hasNotifications' => 0, 'recipients' => array()), array('has_changed' => 0, 'isNotificationsSupported' => 1, 'hasNotifications' => 1, 'recipients' => array('a_user')), array('has_changed' => 0, 'isNotificationsSupported' => 1, 'hasNotifications' => 0, 'recipients' => array('should_not_appear')), array('has_changed' => 0, 'isNotificationsSupported' => 0, 'hasNotifications' => 1, 'recipients' => array('should_not_appear_(not_supported)')), array('has_changed' => 0, 'isNotificationsSupported' => 1, 'hasNotifications' => 1, 'recipients' => array('multiple_users', '*****@*****.**')));
        $fact = new MockTracker_FormElementFactory();
        $dar = new MockDataAccessResult();
        $dao = new MockTracker_Artifact_Changeset_ValueDao();
        $artifact = new MockTracker_Artifact();
        $tracker = new MockTracker();
        $um = new MockUserManager();
        $i = 0;
        // try DRY in unit tests also... build mocks automatically
        foreach ($defs as $d) {
            $id = $i + 1;
            $changeset_value_id = 1000 + $id;
            $dar->setReturnValueAt($i++, 'current', array('changeset_id' => 66, 'field_id' => $id, 'id' => $changeset_value_id, 'has_changed' => $d['has_changed']));
            $f = new MockTracker_FormElement_Field_Selectbox();
            $fact->setReturnReference('getFieldById', $f, array($id));
            $f->setReturnValue('getId', $id);
            $f->setReturnValue('getLabel', 'field_' . $id);
            $f->setReturnValue('isNotificationsSupported', $d['isNotificationsSupported']);
            $f->setReturnValue('hasNotifications', $d['hasNotifications']);
            $f->setReturnValue('getRecipients', $d['recipients']);
            $p = new MockTracker_Artifact_ChangesetValue_List();
            $c = new MockTracker_Artifact_ChangesetValue_List();
            $c->setReturnValue('hasChanged', $d['has_changed']);
            $c->setReturnValue('diff', 'has changed', array($p));
            $f->setReturnReference('getChangesetValue', $c, array('*', $changeset_value_id, $d['has_changed']));
            unset($f);
        }
        $dar->setReturnValue('valid', true);
        $dar->setReturnValueAt($i, 'valid', false);
        $dao->setReturnReference('searchById', $dar);
        $artifact->setReturnReference('getTracker', $tracker);
        $artifact->setReturnValue('getCommentators', array('comment1', 'comment2'));
        $artifact->setReturnValue('getId', 666);
        $tracker->setReturnValue('getItemName', 'story');
        $tracker->setReturnValue('isNotificationStopped', false);
        $tracker->setReturnValue('getRecipients', array(array('recipients' => array('global1', 'global2'), 'on_updates' => false, 'check_permissions' => true), array('recipients' => array('dont_check_perms', 'global3', '*****@*****.**'), 'on_updates' => true, 'check_permissions' => false)));
        $current_changeset = new Tracker_Artifact_ChangesetTestVersion();
        $current_changeset->setReturnValue('getId', 66);
        $current_changeset->setReturnReference('getValueDao', $dao);
        $current_changeset->setReturnReference('getFormElementFactory', $fact);
        $current_changeset->setReturnReference('getArtifact', $artifact);
        $current_changeset->setReturnReference('getUserManager', $um);
        $current_changeset->setReturnReference('getTracker', $tracker);
        $expected_body = <<<BODY
story #666
<http://{$GLOBALS['sys_default_domain']}/tracker/?aid=666>

BODY;
        $current_changeset->expect('sendNotification', array(array('a_user', 'multiple_users', '*****@*****.**', 'dont_check_perms', 'global3', 'comment1', 'comment2'), array(), '[story #666]', $expected_body));
        $current_changeset->notify();
    }
Exemplo n.º 10
0
 function testDontCreateNewChangesetIfNoCommentOrNoChanges()
 {
     $this->language->setReturnValue('getText', 'no changes', array('plugin_tracker_artifact', 'no_changes', '*'));
     $this->response->expectOnce('addFeedback', array('info', 'no changes', CODENDI_PURIFIER_LIGHT));
     $comment_dao = new MockTracker_Artifact_Changeset_CommentDao();
     $comment_dao->expectNever('createNewVersion');
     $dao = new MockTracker_Artifact_ChangesetDao();
     $dao->expectNever('create');
     $user = new MockUser();
     $user->setReturnValue('getId', 1234);
     $user->setReturnValue('isAnonymous', false);
     $tracker = new MockTracker();
     $factory = new MockTracker_FormElementFactory();
     $rules_manager = new MockTracker_RulesManager();
     $rules_manager->setReturnValue('validate', true);
     $tracker->setReturnReference('getRulesManager', $rules_manager);
     $field1 = new MockTracker_FormElement_Field();
     $field1->setReturnValue('getId', 101);
     $field1->setReturnValue('isValid', true);
     $field1->setReturnValue('userCanUpdate', true);
     $field1->expectNever('saveNewChangeset');
     $field2 = new MockTracker_FormElement_Field();
     $field2->setReturnValue('getId', 102);
     $field2->setReturnValue('isValid', true);
     $field2->setReturnValue('userCanUpdate', true);
     $field2->expectNever('saveNewChangeset');
     $field3 = new MockTracker_FormElement_Field();
     $field3->setReturnValue('getId', 103);
     $field3->setReturnValue('isValid', true);
     $field3->setReturnValue('userCanUpdate', true);
     $field3->expectNever('saveNewChangeset');
     $factory->setReturnValue('getUsedFields', array($field1, $field2, $field3));
     $changeset = new MockTracker_Artifact_Changeset();
     $changeset->setReturnValue('hasChanges', false);
     $changeset_value1 = new MockTracker_Artifact_ChangesetValue();
     $changeset_value2 = new MockTracker_Artifact_ChangesetValue();
     $changeset_value3 = new MockTracker_Artifact_ChangesetValue();
     $changeset->setReturnReference('getValue', $changeset_value1, array($field1));
     $changeset->setReturnReference('getValue', $changeset_value2, array($field2));
     $changeset->setReturnReference('getValue', $changeset_value3, array($field3));
     $artifact = new Tracker_ArtifactTestVersion();
     $artifact->setReturnReference('getChangesetDao', $dao);
     $artifact->setReturnReference('getChangesetCommentDao', $comment_dao);
     $artifact->setReturnReference('getFormElementFactory', $factory);
     $artifact->setReturnReference('getTracker', $tracker);
     $artifact->setReturnValue('getId', 66);
     $artifact->setReturnReference('getLastChangeset', $changeset);
     $workflow = new MockWorkflow();
     $workflow->expectNever('before');
     $artifact->setReturnValue('getWorkflow', $workflow);
     $email = null;
     //not annonymous user
     $comment = '';
     //empty comment
     // Valid
     $fields_data = array();
     $artifact->createNewChangeset($fields_data, $comment, $user, $email);
 }
Exemplo n.º 11
0
 function setUp()
 {
     // Fields:
     // F1(A1, A2)
     // F2(B1, B2, B3)
     // F3(C1, C2)
     // F4(D1, D2)
     //
     // Rules:
     // F1(A1) => F2(B1, B3) The resource A1 can be used in rooms B1 and B3
     // F1(A2) => F2(B2, B3) The resource A2 can be used in rooms B2 and B3
     // F2(B1) => F3(C1) The person C1 can access to rooms B1 and B3
     // F2(B2) => F3(C2)     The person C2 can access to room B2 only
     // F2(B3) => F3(C1)     The person C1 can access to rooms B1 and B3
     //
     // Scenarios:
     // S1 => A2, B3, C1, D1 should be valid (C2 can use A2 in B3)
     // S2 => A2, B3, C2, D1 should *not* be valid (C2 cannot access to B3)
     // S3 => (A1, A2), B3, C1, D1 should be valid
     // S4 => (A1, A2), B2, C2, D1 should be valid (even if A1 cannot access to B2)
     // S5 => A1, (B1, B3), C1, D1 should be valid
     // S6 => A1, (B1, B2), C1, D1 should *not* be valid (A1 or C1 cannot access to B2)
     $r1 = new Tracker_Rule_List(1, 1, 'F1', 'A1', 'F2', 'B1');
     $r2 = new Tracker_Rule_List(2, 1, 'F1', 'A1', 'F2', 'B3');
     $r3 = new Tracker_Rule_List(3, 1, 'F1', 'A2', 'F2', 'B2');
     $r4 = new Tracker_Rule_List(4, 1, 'F1', 'A2', 'F2', 'B3');
     $r5 = new Tracker_Rule_List(5, 1, 'F2', 'B1', 'F3', 'C1');
     $r6 = new Tracker_Rule_List(6, 1, 'F2', 'B2', 'F3', 'C2');
     $r7 = new Tracker_Rule_List(7, 1, 'F2', 'B3', 'F3', 'C1');
     $arf = new MockTracker_RuleFactory($this);
     $arf->setReturnValue('getAllListRulesByTrackerWithOrder', array($r1, $r2, $r3, $r4, $r5, $r6, $r7));
     $f1 = new MockTracker_FormElement_Field_Selectbox($this);
     $f1->setReturnReference('getBind', $bind);
     $f1->setReturnValue('getID', 'F1');
     $f1->setReturnValue('getLabel', 'f_1');
     $f1->setReturnValue('getAllValues', null);
     $f2 = new MockTracker_FormElement_Field_Selectbox($this);
     $f2->setReturnReference('getBind', $bind);
     $f2->setReturnValue('getID', 'F2');
     $f2->setReturnValue('getLabel', 'f_2');
     $f2->setReturnValue('getAllValues', null);
     $f3 = new MockTracker_FormElement_Field_Selectbox($this);
     $f3->setReturnReference('getBind', $bind);
     $f3->setReturnValue('getID', 'F3');
     $f3->setReturnValue('getLabel', 'f_3');
     $f3->setReturnValue('getAllValues', null);
     $f4 = new MockTracker_FormElement_Field_Selectbox($this);
     $f4->setReturnReference('getBind', $bind);
     $f4->setReturnValue('getID', 'F4');
     $f4->setReturnValue('getLabel', 'f_4');
     $f4->setReturnValue('getAllValues', null);
     $aff = new MockTracker_FormElementFactory($this);
     $aff->setReturnReference('getFormElementById', $f1, array('F1'));
     $aff->setReturnReference('getFormElementById', $f2, array('F2'));
     $aff->setReturnReference('getFormElementById', $f3, array('F3'));
     $aff->setReturnReference('getFormElementById', $f4, array('F4'));
     $rule_date_factory = mock('Tracker_Rule_Date_Factory');
     stub($rule_date_factory)->searchByTrackerId()->returns(array());
     $this->arm = new Tracker_RulesManagerTestVersion($this);
     $this->arm->setTrackerFormElementFactory($aff);
     $this->arm->setRuleDateFactory($rule_date_factory);
     $this->arm->setReturnReference('getRuleFactory', $arf);
     $this->arm->setReturnValue('getSelectedValuesForField', array('a_1'), array($f1, 'A1'));
     $this->arm->setReturnValue('getSelectedValuesForField', array('a_2'), array($f1, 'A2'));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_1'), array($f2, 'B1'));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_2'), array($f2, 'B2'));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_3'), array($f2, 'B3'));
     $this->arm->setReturnValue('getSelectedValuesForField', array('c_1'), array($f3, 'C1'));
     $this->arm->setReturnValue('getSelectedValuesForField', array('c_2'), array($f3, 'C2'));
     $this->arm->setReturnValue('getSelectedValuesForField', array('a_1'), array($f1, array('A1')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('a_2'), array($f1, array('A2')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_1'), array($f2, array('B1')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_2'), array($f2, array('B2')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_3'), array($f2, array('B3')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('c_1'), array($f3, array('C1')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('c_2'), array($f3, array('C2')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('a_1', 'a_2'), array($f1, array('A1', 'A2')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_1', 'b_3'), array($f2, array('B1', 'B3')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_1', 'b_2'), array($f2, array('B1', 'B2')));
     $this->arm->setReturnValue('getSelectedValuesForField', array('b_2', 'b_3'), array($f2, array('B2', 'B3')));
 }