public function testLoad()
 {
     $customFieldData = CustomFieldData::getByName('Titles');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('AccountTypes');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('LeadSources');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('Industries');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('MeetingCategories');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $this->assertEquals(0, ContactState::getCount());
     // do a getAll to ensure we create base currency
     $baseCurrency = Currency::getAll();
     $this->assertCount(1, $baseCurrency);
     $this->assertEquals(1, Currency::getCount());
     $messageLogger = new MessageLogger();
     DefaultDataUtil::load($messageLogger);
     $customFieldData = CustomFieldData::getByName('Titles');
     $this->assertEquals(4, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('AccountTypes');
     $this->assertEquals(3, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('LeadSources');
     $this->assertEquals(4, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('Industries');
     $this->assertEquals(9, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('MeetingCategories');
     $this->assertEquals(2, count(unserialize($customFieldData->serializedData)));
     $this->assertEquals(6, ContactState::getCount());
     $this->assertEquals(1, Currency::getCount());
 }
示例#2
0
 public function testGetAllMakesBaseCurrency()
 {
     $this->assertEquals(0, count(Currency::getAll(null, false, null, false)));
     $currency = Yii::app()->currencyHelper;
     $this->assertEquals('USD', $currency->getBaseCode());
     $this->assertEquals(0, Currency::getCount());
     $this->assertEquals(1, count(Currency::getAll()));
     $this->assertEquals(1, Currency::getCount());
 }
示例#3
0
 public function testGetAllMakesBaseCurrency()
 {
     $this->assertEquals(0, count(Currency::getAll(null, false, null, false)));
     $currency = Yii::app()->currencyHelper;
     $this->assertEquals('USD', $currency->getBaseCode());
     $this->assertEquals(0, Currency::getCount());
     // do a getAll to ensure we create base currency
     $baseCurrency = Currency::getAll();
     $this->assertCount(1, $baseCurrency);
     $this->assertEquals(1, Currency::getCount());
 }
 public function _new()
 {
     $flash = Flash::Instance();
     $errors = array();
     $currency = new Currency();
     if ($currency->getCount() == 0) {
         $errors[] = 'No Currencies defined';
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
         sendback();
     }
     parent::_new();
 }
 public function testGetAndSetCurrencyValue()
 {
     $currencyHelper = Yii::app()->currencyHelper;
     $this->assertEquals('USD', $currencyHelper->getBaseCode());
     $this->assertEquals(0, Currency::getCount());
     // do a getAll to ensure we create base currency
     $baseCurrency = Currency::getAll();
     $this->assertCount(1, $baseCurrency);
     $this->assertEquals(1, Currency::getCount());
     //create a currency value and confirm the rateToBase populates correctly.
     $opportunity = new Opportunity();
     $opportunity->name = 'Tyfe';
     $opportunity->stage->value = 'Starting Up';
     $opportunity->closeDate = '2008-10-05';
     $opportunity->amount->value = 456.78;
     //Setting the amount currency should not increase the currency table with a blank currency.
     $this->assertEquals(1, Currency::getCount());
     $opportunity->amount->currency = Currency::getByCode('USD');
     $this->assertEquals(1, Currency::getCount());
     $this->assertTrue($opportunity->save());
     $this->assertEquals(1, $opportunity->amount->rateToBase);
     $this->assertEquals(Currency::getByCode('USD'), $opportunity->amount->currency);
 }