function testGetChangesetValue()
 {
     $value_dao = new $this->dao_class();
     $dar = new MockDataAccessResult();
     $dar->setReturnValueAt(0, 'current', array('id' => '123', 'field_id' => '1', 'bindvalue_id' => '1000'));
     $dar->setReturnValueAt(1, 'current', array('id' => '123', 'field_id' => '1', 'bindvalue_id' => '1001'));
     $dar->setReturnValueAt(2, 'current', array('id' => '123', 'field_id' => '1', 'bindvalue_id' => '1002'));
     $dar->setReturnValue('valid', true);
     $dar->setReturnValueAt(3, 'valid', false);
     $value_dao->setReturnReference('searchById', $dar);
     $bind = new MockTracker_FormElement_Field_List_Bind();
     $bind->setReturnValue('getBindValues', array_fill(0, 3, new MockTracker_FormElement_Field_List_BindValue()));
     $list_field = new $this->field_class();
     $list_field->setReturnReference('getValueDao', $value_dao);
     $list_field->setReturnReference('getBind', $bind);
     $changeset_value = $list_field->getChangesetValue(null, 123, false);
     $this->assertIsA($changeset_value, $this->cv_class);
     $this->assertTrue(is_array($changeset_value->getListValues()));
     $this->assertEqual(count($changeset_value->getListValues()), 3);
     foreach ($changeset_value->getListValues() as $bv) {
         $this->assertIsA($bv, 'Tracker_FormElement_Field_List_BindValue');
     }
 }
 function testGetFieldData()
 {
     $bind = new MockTracker_FormElement_Field_List_Bind();
     $bind->setReturnValue('getFieldData', '115', array('existing value', '*'));
     $bind->setReturnValue('getFieldData', '118', array('yet another existing value', '*'));
     $bind->setReturnValue('getFieldData', null, array('new value', '*'));
     $bind->setReturnValue('getFieldData', null, array('yet another new value', '*'));
     $bind->setReturnValue('getFieldData', null, array('existing open value', '*'));
     $bind->setReturnValue('getFieldData', null, array('yet another existing open value', '*'));
     $bind->setReturnValue('getFieldData', null, array('', '*'));
     $odar = new MockDataAccessResult();
     $odar->setReturnValue('getRow', false);
     $open_value_dao = new MockTracker_FormElement_Field_List_OpenValueDao();
     $odar_30 = new MockDataAccessResult();
     $odar_30->setReturnValue('getRow', array('id' => '30', 'field_id' => '1', 'label' => 'existing open value'));
     $odar_40 = new MockDataAccessResult();
     $odar_40->setReturnValue('getRow', array('id' => '40', 'field_id' => '1', 'label' => 'yet another existing open value'));
     $open_value_dao->setReturnReference('searchByExactLabel', $odar_30, array(1, 'existing open value'));
     $open_value_dao->setReturnReference('searchByExactLabel', $odar_40, array(1, 'yet another existing open value'));
     $open_value_dao->setReturnReference('searchByExactLabel', $odar, array(1, 'new value'));
     $open_value_dao->setReturnReference('searchByExactLabel', $odar, array(1, 'yet another new value'));
     $open_value_dao->setReturnReference('searchByExactLabel', $odar, array(1, ''));
     $f = new Tracker_FormElement_Field_OpenListTestVersion();
     $f->setReturnReference('getOpenValueDao', $open_value_dao);
     $f->setReturnReference('getBind', $bind);
     $f->setReturnValue('getId', 1);
     $this->assertEqual("!new value,!yet another new value", $f->getFieldData('new value,yet another new value', true));
     $this->assertEqual("!new value,b115", $f->getFieldData('new value,existing value', true));
     $this->assertEqual("!new value,o30,b115", $f->getFieldData('new value,existing open value,existing value', true));
     $this->assertNull($f->getFieldData('', true));
 }