/**
  * created customfield config
  * 
  * @return Tinebase_Model_CustomField_Config
  */
 protected function _createCustomfield($cfName = NULL)
 {
     $cfName = $cfName !== NULL ? $cfName : Tinebase_Record_Abstract::generateUID();
     $cfc = Tinebase_CustomFieldTest::getCustomField(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'model' => 'Addressbook_Model_Contact', 'name' => $cfName));
     $createdCustomField = Tinebase_CustomField::getInstance()->addCustomField($cfc);
     $this->_customfieldIdsToDelete[] = $createdCustomField->getId();
     return $createdCustomField;
 }
 /**
  * get lead
  * 
  * @param boolean $addCf
  * @param boolean $addTags
  * @return Crm_Model_Lead
  */
 protected function _getLead($addCf = TRUE, $addTags = TRUE)
 {
     if ($addCf) {
         $cfc = Tinebase_CustomFieldTest::getCustomField(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Crm')->getId(), 'model' => 'Crm_Model_Lead', 'name' => Tinebase_Record_Abstract::generateUID()));
         $this->_cfcName = $cfc->name;
         $cfs = array($this->_cfcName => '1234');
         Tinebase_CustomField::getInstance()->addCustomField($cfc);
     } else {
         $cfs = array();
     }
     if ($addTags) {
         $tags = array(array('name' => 'lead tag', 'type' => Tinebase_Model_Tag::TYPE_SHARED));
     } else {
         $tags = array();
     }
     return new Crm_Model_Lead(array('lead_name' => 'PHPUnit', 'leadstate_id' => 1, 'leadtype_id' => 1, 'leadsource_id' => 1, 'container_id' => Tinebase_Container::getInstance()->getDefaultContainer('Crm')->getId(), 'start' => Tinebase_DateTime::now(), 'description' => 'Description', 'end' => NULL, 'turnover' => 0, 'probability' => 70, 'end_scheduled' => NULL, 'tags' => $tags, 'customfields' => $cfs));
 }
<?php

/**
 * Tine 2.0 - http://www.tine20.org
 * 
 * @package     Tinebase
 * @license     http://www.gnu.org/licenses/agpl.html
 * @copyright   Copyright (c) 2009-2010 Metaways Infosystems GmbH (http://www.metaways.de)
 * @author      Philipp Schuele <*****@*****.**>
 */
/**
 * Test helper
 */
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php';
if (!defined('PHPUnit_MAIN_METHOD')) {
    Tinebase_CustomFieldTest::main();
}
/**
 * Test class for Tinebase_CustomField
 */
class Tinebase_CustomFieldTest extends PHPUnit_Framework_TestCase
{
    /**
     * unit under test (UIT)
     * @var Tinebase_CustomField
     */
    protected $_instance;
    /**
     * @var array test objects
     */
    protected $_objects = array();