function testGetFieldDataMultiple() { $bv1 = new MockTracker_FormElement_Field_List_Bind_StaticValue(); $bv1->setReturnValue('getLabel', 'Admin'); $bv2 = new MockTracker_FormElement_Field_List_Bind_StaticValue(); $bv2->setReturnValue('getLabel', 'Tracker'); $bv3 = new MockTracker_FormElement_Field_List_Bind_StaticValue(); $bv3->setReturnValue('getLabel', 'User Interface'); $bv4 = new MockTracker_FormElement_Field_List_Bind_StaticValue(); $bv4->setReturnValue('getLabel', 'Docman'); $field = $is_rank_alpha = $default_values = $decorators = ''; $values = array(13564 => $bv1, 13987 => $bv2, 125 => $bv3, 666 => $bv4); $res = array('13564', '125', '666'); $f = new Tracker_FormElement_Field_List_Bind_Static($field, $is_rank_alpha, $values, $default_values, $decorators); $this->assertEqual($res, $f->getFieldData('Admin,User Interface,Docman', true)); }
public function testGetSoapAvailableValues() { $bv1 = new MockTracker_FormElement_Field_List_Bind_StaticValue(); $bv1->setReturnValue('getId', 101); $bv1->setReturnValue('getSoapValue', 'bv label 1'); $bv2 = new MockTracker_FormElement_Field_List_Bind_StaticValue(); $bv2->setReturnValue('getId', 102); $bv2->setReturnValue('getSoapValue', 'bv label 2'); $field = new MockTracker_FormElement_Field_List(); $field->setReturnValue('getId', 123); $is_rank_alpha = $default_values = $decorators = ''; $values = array(101 => $bv1, 102 => $bv2); $static = new Tracker_FormElement_Field_List_Bind_Static($field, $is_rank_alpha, $values, $default_values, $decorators); $this->assertEqual(count($static->getSoapAvailableValues()), 2); $soap_values = array(array('bind_value_id' => 101, 'bind_value_label' => 'bv label 1'), array('bind_value_id' => 102, 'bind_value_label' => 'bv label 2')); $this->assertEqual($static->getSoapAvailableValues(), $soap_values); }
/** * Create a bind for the field * * @param Field $field the field * @param string $type the type of bind. If empty, STATIK * @param array $bind_data the data used to create the bind * * @return Bind null if error */ public function createBind($field, $type, $bind_data) { $bind = null; switch ($type) { case '': //default is static //default is static case self::STATIK: $dao = new Tracker_FormElement_Field_List_Bind_StaticDao(); if ($dao->save($field->getId(), 0)) { $bind = new Tracker_FormElement_Field_List_Bind_Static($field, 0, array(), array(), array()); $bind->process($bind_data, 'no redirect'); } break; case self::USERS: $dao = new Tracker_FormElement_Field_List_Bind_UsersDao(); if ($dao->save($field->getId(), array())) { $bind = new Tracker_FormElement_Field_List_Bind_Users($field, '', array(), array()); $bind->process($bind_data, 'no redirect'); } break; case self::UGROUPS: $bind = new Tracker_FormElement_Field_List_Bind_Ugroups($field, array(), array(), array(), $this->ugroup_manager, $this->getUgroupsValueDao()); $bind->process($bind_data, 'no redirect'); break; default: break; } return $bind; }
public function itDoesntCrashWhenInvalidValueShouldBePrinted() { $field = aSelectBoxField()->withId(101)->build(); $bind = new Tracker_FormElement_Field_List_Bind_Static($field, 0, array(), null, null); $this->assertEqual('-', $bind->formatArtifactValue(0)); }