Пример #1
0
 function testGetOriginalProjectAndOriginalTracker()
 {
     $project = new MockProject();
     $tracker = new MockTracker();
     $tracker->setReturnValue('getProject', $project);
     $original = new MockTracker_FormElement_Field_Selectbox();
     $original->setReturnValue('getTracker', $tracker);
     $element = $this->GivenAFormElementWithIdAndOriginalField(null, $original);
     $this->assertEqual($tracker, $element->getOriginalTracker());
     $this->assertEqual($project, $element->getOriginalProject());
 }
 private function GivenAUserSelectbox()
 {
     $tracker = new MockTracker();
     $field = new MockTracker_FormElement_Field_Selectbox();
     $field->setReturnValue('getTracker', $tracker);
     $field->setReturnValue('getBind', new MockTracker_FormElement_Field_List_Bind_Users());
     return $field;
 }
 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')));
 }