本文整理汇总了PHP中Opportunity::getByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Opportunity::getByName方法的具体用法?PHP Opportunity::getByName怎么用?PHP Opportunity::getByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opportunity
的用法示例。
在下文中一共展示了Opportunity::getByName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaveAndRetrievePortlet
public function testSaveAndRetrievePortlet()
{
$user = UserTestHelper::createBasicUser('Billy');
$opportunities = Opportunity::getByName('superOpp');
$portlet = new Portlet();
$portlet->column = 2;
$portlet->position = 5;
$portlet->layoutId = 'Test';
$portlet->collapsed = true;
$portlet->viewType = 'OpportunitiesForContactRelatedList';
$portlet->serializedViewData = serialize(array('title' => 'Testing Title'));
$portlet->user = $user;
$this->assertTrue($portlet->save());
$portlet = Portlet::getById($portlet->id);
$params = array('controllerId' => 'test', 'relationModuleId' => 'test', 'relationModel' => $opportunities[0], 'redirectUrl' => 'someRedirect');
$portlet->params = $params;
$unserializedViewData = unserialize($portlet->serializedViewData);
$this->assertEquals(2, $portlet->column);
$this->assertEquals(5, $portlet->position);
$this->assertEquals('Testing Title', $portlet->getTitle());
$this->assertEquals(false, $portlet->isEditable());
$this->assertEquals('Test', $portlet->layoutId);
//$this->assertEquals(true, $portlet->collapsed); //reenable once working
$this->assertEquals('OpportunitiesForContactRelatedList', $portlet->viewType);
$this->assertEquals($user->id, $portlet->user->id);
$view = $portlet->getView();
}
示例2: testProductSaveWithPermissions
public function testProductSaveWithPermissions()
{
Yii::app()->user->userModel = User::getByUsername('super');
$contacts = Contact::getAll();
$accounts = Account::getByName('superAccount');
$opportunities = Opportunity::getByName('superOpportunity');
$productTemplates = ProductTemplate::getByName('superProductTemplate');
$account = $accounts[0];
$user = $account->owner;
$everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
$explicitReadWriteModelPermissions = new ExplicitReadWriteModelPermissions();
$currencyHelper = Yii::app()->currencyHelper;
$currencyCode = $currencyHelper->getBaseCode();
$currency = Currency::getByCode($currencyCode);
$postData = array('productTemplate' => array('id' => $productTemplates[0]->id), 'name' => 'ProductPermissionTest', 'quantity' => 6, 'account' => array('id' => $accounts[0]->id), 'contact' => array('id' => $contacts[0]->id), 'opportunity' => array('id' => ''), 'type' => ProductTemplate::TYPE_PRODUCT, 'priceFrequency' => ProductTemplate::PRICE_FREQUENCY_ONE_TIME, 'sellPrice' => array('currency' => array('id' => $currency->id), 'value' => 210), 'stage' => array('value' => 'Open'), 'owner' => array('id' => $user->id), 'explicitReadWriteModelPermissions' => array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP, 'nonEveryoneGroup' => ''));
$model = new Product();
$sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($model, $postData);
if ($model instanceof SecurableItem) {
$explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake($sanitizedPostData, $model);
} else {
$explicitReadWriteModelPermissions = null;
}
$readyToUseData = ExplicitReadWriteModelPermissionsUtil::removeIfExistsFromPostData($sanitizedPostData);
$sanitizedOwnerData = PostUtil::sanitizePostDataToJustHavingElementForSavingModel($readyToUseData, 'owner');
$sanitizedDataWithoutOwner = PostUtil::removeElementFromPostDataForSavingModel($readyToUseData, 'owner');
$model->setAttributes($sanitizedDataWithoutOwner);
if ($model->validate()) {
$modelToStringValue = strval($model);
if ($sanitizedOwnerData != null) {
$model->setAttributes($sanitizedOwnerData);
}
if ($model instanceof OwnedSecurableItem) {
$passedOwnerValidation = $model->validate(array('owner'));
} else {
$passedOwnerValidation = true;
}
if ($passedOwnerValidation && $model->save(false)) {
if ($explicitReadWriteModelPermissions != null) {
$success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($model, $explicitReadWriteModelPermissions);
//todo: handle if success is false, means adding/removing permissions save failed.
}
$savedSuccessfully = true;
}
} else {
}
$this->assertEquals('ProductPermissionTest', $model->name);
}
示例3: testGetItemIdsByModelAndUser
public function testGetItemIdsByModelAndUser()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$headquarters = Account::getByName('Headquarters');
$headquarters = $headquarters[0];
$division1 = Account::getByName('Division1');
$division1 = $division1[0];
$division2 = Account::getByName('Division2');
$division2 = $division2[0];
$ceo = Contact::getByName('ceo ceoson');
$ceo = $ceo[0];
$div1President = Contact::getByName('div1 President div1 Presidentson');
$div1President = $div1President[0];
$div2President = Contact::getByName('div2 President div2 Presidentson');
$div2President = $div2President[0];
$opportunity = Opportunity::getByName('big opp');
$opportunity = $opportunity[0];
$opportunityDiv1 = Opportunity::getByName('div1 small opp');
$opportunityDiv1 = $opportunityDiv1[0];
$opportunityDiv2 = Opportunity::getByName('div2 small opp');
$opportunityDiv2 = $opportunityDiv2[0];
//Headquarter rollup should include all items created so far.
$this->assertEquals(2, $headquarters->accounts->count());
$itemIds = ModelRollUpUtil::getItemIdsByModelAndUser($headquarters, $super);
$compareItemIds = array();
$this->assertEquals(9, count($itemIds));
$this->assertTrue(in_array($headquarters->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($division1->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($division2->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($ceo->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($div1President->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($div2President->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($opportunity->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($opportunityDiv1->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($opportunityDiv2->getClassId('Item'), $itemIds));
//Ceo rollup would only include the ceo and his opportunity
$itemIds = ModelRollUpUtil::getItemIdsByModelAndUser($ceo, $super);
$compareItemIds = array();
$this->assertEquals(2, count($itemIds));
$this->assertTrue(in_array($ceo->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($opportunity->getClassId('Item'), $itemIds));
//Big Opp rollup will only include big opp and ceo
$itemIds = ModelRollUpUtil::getItemIdsByModelAndUser($opportunity, $super);
$compareItemIds = array();
$this->assertEquals(2, count($itemIds));
$this->assertTrue(in_array($ceo->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($opportunity->getClassId('Item'), $itemIds));
//Division 1 rollup will only include things related to division 1
$itemIds = ModelRollUpUtil::getItemIdsByModelAndUser($division1, $super);
$compareItemIds = array();
$this->assertEquals(3, count($itemIds));
$this->assertTrue(in_array($division1->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($div1President->getClassId('Item'), $itemIds));
$this->assertTrue(in_array($opportunityDiv1->getClassId('Item'), $itemIds));
}
示例4: testSuperUserCopyAction
/**
* @depends testSuperUserCreateFromRelationAction
*/
public function testSuperUserCopyAction()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$currencies = Currency::getAll();
$opportunities = Opportunity::getByName('myNewOpportunity');
$this->assertCount(1, $opportunities);
$postArray = array('Opportunity' => array('name' => 'myNewOpportunity', 'amount' => array('value' => '1000', 'currency' => array('id' => $currencies[0]->id)), 'account' => array('name' => 'Linked account'), 'closeDate' => '2012-11-01', 'probability' => 50, 'stage' => array('value' => 'Negotiating'), 'description' => 'some description'));
$this->updateModelValuesFromPostArray($opportunities[0], $postArray);
$this->assertModelHasValuesFromPostArray($opportunities[0], $postArray);
$this->assertTrue($opportunities[0]->save());
unset($postArray['Opportunity']['closeDate']);
$this->assertTrue($this->checkCopyActionResponseAttributeValuesFromPostArray($opportunities[0], $postArray, 'Opportunities'));
$postArray['Opportunity']['name'] = 'myNewClonedOpportunity';
$postArray['Opportunity']['closeDate'] = '11/1/12';
$this->setGetArray(array('id' => $opportunities[0]->id));
$this->setPostArray($postArray);
$this->runControllerWithRedirectExceptionAndGetUrl('opportunities/default/copy');
$opportunities = Opportunity::getByName('myNewClonedOpportunity');
$this->assertCount(1, $opportunities);
$this->assertTrue($opportunities[0]->owner->isSame($super));
$postArray['Opportunity']['closeDate'] = '2012-11-01';
$this->assertModelHasValuesFromPostArray($opportunities[0], $postArray);
$opportunities = Opportunity::getAll();
$this->assertCount(15, $opportunities);
$opportunities = Opportunity::getByName('myNewClonedOpportunity');
$this->assertCount(1, $opportunities);
$this->assertTrue($opportunities[0]->delete());
}
示例5: testGetOpportunitiesThatAreRelatedWithContact
/**
* Test get opportunities that are releted with contacts(MANY_MANY relationship)
* @depends testDynamicSearchOpportunities
*/
public function testGetOpportunitiesThatAreRelatedWithContact()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$firstContact = ContactTestHelper::createContactByNameForOwner('First Contact', $super);
$secondContact = ContactTestHelper::createContactByNameForOwner('Second Contact', $super);
$opportunities = Opportunity::getByName('First Opportunity');
$firstOpportunity = $opportunities[0];
$opportunities = Opportunity::getByName('Second Opportunity');
$secondOpportunity = $opportunities[0];
$opportunities = Opportunity::getByName('Third Opportunity');
$thirdOpportunity = $opportunities[0];
$opportunities = Opportunity::getByName('Forth Opportunity');
$forthOpportunity = $opportunities[0];
$firstContact->opportunities->add($firstOpportunity);
$firstContact->opportunities->add($secondOpportunity);
$firstContact->opportunities->add($thirdOpportunity);
$firstContact->save();
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
$data = array('dynamicSearch' => array('dynamicClauses' => array(array('attributeIndexOrDerivedType' => 'contacts' . FormModelUtil::RELATION_DELIMITER . 'id', 'structurePosition' => 1, 'contacts' => array('id' => $firstContact->id))), 'dynamicStructure' => '1'), 'pagination' => array('page' => 1, 'pageSize' => 2), 'sort' => 'name.desc');
$response = $this->createApiCallWithRelativeUrl('list/filter/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(2, count($response['data']['items']));
$this->assertEquals(3, $response['data']['totalCount']);
$this->assertEquals(1, $response['data']['currentPage']);
$this->assertEquals('Third Opportunity', $response['data']['items'][0]['name']);
$this->assertEquals('Second Opportunity', $response['data']['items'][1]['name']);
// Get second page
$data['pagination']['page'] = 2;
$response = $this->createApiCallWithRelativeUrl('list/filter/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(1, count($response['data']['items']));
$this->assertEquals(3, $response['data']['totalCount']);
$this->assertEquals(2, $response['data']['currentPage']);
$this->assertEquals('First Opportunity', $response['data']['items'][0]['name']);
}
示例6: testUpdateOpportunityFromForm
/**
* @depends testCreateAndGetOpportunityById
*/
public function testUpdateOpportunityFromForm()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = User::getByUsername('billy');
$opportunities = Opportunity::getByName('Test Opportunity');
$opportunity = $opportunities[0];
$this->assertEquals($opportunity->name, 'Test Opportunity');
$currencies = Currency::getAll();
$postData = array('owner' => array('id' => $user->id), 'name' => 'New Name', 'amount' => array('value' => '500.54', 'currency' => array('id' => $currencies[0]->id)), 'closeDate' => '2011-01-01', 'stage' => array('value' => 'Negotiating'));
$opportunity->setAttributes($postData);
$this->assertTrue($opportunity->save());
$id = $opportunity->id;
unset($opportunity);
$opportunity = Opportunity::getById($id);
$this->assertEquals('New Name', $opportunity->name);
$this->assertEquals(500.54, $opportunity->amount->value);
$this->assertEquals(50, $opportunity->probability);
$this->assertEquals(1, $currencies[0]->rateToBase);
//Updating probability mapping should make changes on saving opportunity
$metadata = OpportunitiesModule::getMetadata();
$metadata['global']['stageToProbabilityMapping']['Negotiating'] = 60;
OpportunitiesModule::setMetadata($metadata);
$postData = array();
$opportunity->setAttributes($postData);
$this->assertTrue($opportunity->save());
unset($opportunity);
$opportunity = Opportunity::getById($id);
$this->assertEquals('New Name', $opportunity->name);
$this->assertEquals(500.54, $opportunity->amount->value);
$this->assertEquals(60, $opportunity->probability);
$this->assertEquals(1, $currencies[0]->rateToBase);
}
示例7: testDeleteOfTheOpportunityUserForTheCustomFieldsPlacedForOpportunitiesModule
/**
* @depends testWhetherSearchWorksForTheCustomFieldsPlacedForOpportunitiesModuleAfterEditingTheOpportunity
*/
public function testDeleteOfTheOpportunityUserForTheCustomFieldsPlacedForOpportunitiesModule()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Get the opportunity id from the recently edited opportunity.
$opportunityId = self::getModelIdByModelNameAndName('Opportunity', 'myEditOpportunity');
//Set the opportunity id so as to delete the opportunity.
$this->setGetArray(array('id' => $opportunityId));
$this->runControllerWithRedirectExceptionAndGetUrl('opportunities/default/delete');
//Check wether the opportunity is deleted.
$opportunity = Opportunity::getByName('myEditOpportunity');
$this->assertEquals(0, count($opportunity));
}
开发者ID:KulturedKitsch,项目名称:kulturedkitsch.info,代码行数:15,代码来源:OpportunitiesDesignerSuperUserWalkthroughTest.php
示例8: testGetGlobalSearchResultsByPartialTermWithRegularUserAndElevationStepsForRegularUser
/**
* @depends testGetGlobalSearchResultsByPartialTermUsingScope
*/
public function testGetGlobalSearchResultsByPartialTermWithRegularUserAndElevationStepsForRegularUser()
{
//Unfrozen, there are too many attributes that have to be columns in the database at this point, so
//now this is just a frozen test.
if (RedBeanDatabase::isFrozen()) {
$super = User::getByUsername('super');
$jimmy = User::getByUsername('jimmy');
Yii::app()->user->userModel = $super;
//Jimmy does not have read access, so he should not be able to see any results.
$this->assertEquals(Right::DENY, $jimmy->getEffectiveRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS));
$this->assertEquals(Right::DENY, $jimmy->getEffectiveRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS));
$this->assertEquals(Right::DENY, $jimmy->getEffectiveRight('OpportunitiesModule', OpportunitiesModule::RIGHT_ACCESS_OPPORTUNITIES));
Yii::app()->user->userModel = $jimmy;
$data = ModelAutoCompleteUtil::getGlobalSearchResultsByPartialTerm('animal', 5, Yii::app()->user->userModel);
$this->assertEquals(array(array('href' => '', 'label' => 'No Results Found', 'iconClass' => '')), $data);
//Give Jimmy access to the module, he still will not be able to see results.
Yii::app()->user->userModel = $super;
$jimmy->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS);
$jimmy->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
$jimmy->setRight('LeadsModule', LeadsModule::RIGHT_ACCESS_LEADS);
$jimmy->setRight('OpportunitiesModule', OpportunitiesModule::RIGHT_ACCESS_OPPORTUNITIES);
$this->assertTrue($jimmy->save());
Yii::app()->user->userModel = $jimmy;
$data = ModelAutoCompleteUtil::getGlobalSearchResultsByPartialTerm('animal', 5, Yii::app()->user->userModel);
$this->assertEquals(array(array('href' => '', 'label' => 'No Results Found', 'iconClass' => '')), $data);
//Give Jimmy read on 1 model. The search then should pick up this model.
Yii::app()->user->userModel = $super;
$accounts = Account::getByName('The Zoo');
$this->assertEquals(1, count($accounts));
$account = $accounts[0];
$this->assertEquals(Permission::NONE, $account->getEffectivePermissions($jimmy));
$account->addPermissions($jimmy, Permission::READ);
$this->assertTrue($account->save());
ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($account, $jimmy);
Yii::app()->user->userModel = $jimmy;
$data = ModelAutoCompleteUtil::getGlobalSearchResultsByPartialTerm('animal', 5, Yii::app()->user->userModel);
$this->assertEquals(1, count($data));
$this->assertEquals('The Zoo', $data[0]['label']);
//Give Jimmy read on 2 more models. The search then should pick up these models.
Yii::app()->user->userModel = $super;
$contacts = Contact::getByName('Big Elephant');
$this->assertEquals(1, count($contacts));
$contact = $contacts[0];
$this->assertEquals(Permission::NONE, $contact->getEffectivePermissions($jimmy));
$contact->addPermissions($jimmy, Permission::READ);
$this->assertTrue($contact->save());
ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($contact, $jimmy);
$opportunities = Opportunity::getByName('Animal Crackers');
$this->assertEquals(1, count($opportunities));
$opportunity = $opportunities[0];
$this->assertEquals(Permission::NONE, $opportunity->getEffectivePermissions($jimmy));
$opportunity->addPermissions($jimmy, Permission::READ);
$this->assertTrue($opportunity->save());
ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($opportunity, $jimmy);
Yii::app()->user->userModel = $jimmy;
$data = ModelAutoCompleteUtil::getGlobalSearchResultsByPartialTerm('animal', 5, Yii::app()->user->userModel);
$this->assertEquals(3, count($data));
$this->assertEquals('The Zoo', $data[0]['label']);
$this->assertEquals('Big Elephant', $data[1]['label']);
$this->assertEquals('Animal Crackers', $data[2]['label']);
}
}
示例9: testImportWithRateAndCurrencyCodeSpecified
/**
* There is a special way you can import rateToBase and currencyCode for an amount attribute.
* if the column data is formatted like: $54.67__1.2__USD then it will split the column and properly
* handle rate and currency code. Eventually this will be exposed in the user interface
*/
public function testImportWithRateAndCurrencyCodeSpecified()
{
Yii::app()->user->userModel = User::getByUsername('super');
$account = AccountTestHelper::createAccountByNameForOwner('Account', Yii::app()->user->userModel);
$accountId = $account->id;
$opportunities = Opportunity::getAll();
$this->assertEquals(0, count($opportunities));
$import = new Import();
$serializedData['importRulesType'] = 'Opportunities';
$serializedData['firstRowIsHeaderRow'] = true;
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importTestIncludingRateAndCurrencyCode.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.opportunities.tests.unit.files'));
//update the ids of the account column to match the parent account.
ZurmoRedBean::exec("update " . $import->getTempTableName() . " set column_3 = " . $account->id . " where id != 1 limit 4");
$this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
// includes header rows.
$currency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
$mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_1' => ImportMappingUtil::makeDateColumnMappingData('closeDate'), 'column_2' => ImportMappingUtil::makeIntegerColumnMappingData('description'), 'column_3' => ImportMappingUtil::makeHasOneColumnMappingData('account'), 'column_4' => ImportMappingUtil::makeDropDownColumnMappingData('stage'), 'column_5' => ImportMappingUtil::makeDropDownColumnMappingData('source'), 'column_6' => ImportMappingUtil::makeCurrencyColumnMappingData('amount', $currency));
$importRules = ImportRulesUtil::makeImportRulesByType('Opportunities');
$page = 0;
$config = array('pagination' => array('pageSize' => 50));
//This way all rows are processed.
$dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
$dataProvider->getPagination()->setCurrentPage($page);
$importResultsUtil = new ImportResultsUtil($import);
$messageLogger = new ImportMessageLogger();
ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
$importResultsUtil->processStatusAndMessagesForEachRow();
//Confirm that 3 models where created.
$opportunities = Opportunity::getAll();
$this->assertEquals(3, count($opportunities));
$opportunities = Opportunity::getByName('opp1');
$this->assertEquals(1, count($opportunities[0]));
$this->assertEquals('opp1', $opportunities[0]->name);
$this->assertEquals('1980-06-03', $opportunities[0]->closeDate);
$this->assertEquals(10, $opportunities[0]->probability);
$this->assertEquals('desc1', $opportunities[0]->description);
$this->assertTrue($opportunities[0]->account->isSame($account));
$this->assertEquals('Prospecting', $opportunities[0]->stage->value);
$this->assertEquals('Self-Generated', $opportunities[0]->source->value);
$this->assertEquals(500, $opportunities[0]->amount->value);
$this->assertEquals(1, $opportunities[0]->amount->rateToBase);
$this->assertEquals('USD', $opportunities[0]->amount->currency->code);
$opportunities = Opportunity::getByName('opp2');
$this->assertEquals(1, count($opportunities[0]));
$this->assertEquals('opp2', $opportunities[0]->name);
$this->assertEquals('1980-06-04', $opportunities[0]->closeDate);
$this->assertEquals(25, $opportunities[0]->probability);
$this->assertEquals('desc2', $opportunities[0]->description);
$this->assertTrue($opportunities[0]->account->isSame($account));
$this->assertEquals('Qualification', $opportunities[0]->stage->value);
$this->assertEquals('Inbound Call', $opportunities[0]->source->value);
$this->assertEquals(501, $opportunities[0]->amount->value);
// $this->assertEquals(2.7, $opportunities[0]->amount->rateToBase);
$this->assertEquals('GBP', $opportunities[0]->amount->currency->code);
$opportunities = Opportunity::getByName('opp3');
$this->assertEquals(1, count($opportunities[0]));
$this->assertEquals('opp3', $opportunities[0]->name);
$this->assertEquals('1980-06-05', $opportunities[0]->closeDate);
$this->assertEquals(50, $opportunities[0]->probability);
$this->assertEquals('desc3', $opportunities[0]->description);
$this->assertTrue($opportunities[0]->account->isSame($account));
$this->assertEquals('Negotiating', $opportunities[0]->stage->value);
$this->assertEquals('Tradeshow', $opportunities[0]->source->value);
$this->assertEquals(502, $opportunities[0]->amount->value);
// $this->assertEquals(3.2, $opportunities[0]->amount->rateToBase);
$this->assertEquals('EUR', $opportunities[0]->amount->currency->code);
//Confirm 10 rows were processed as 'created'.
$this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
//Confirm that 0 rows were processed as 'updated'.
$this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
//Confirm 2 rows were processed as 'errors'.
$this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
$beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
$this->assertEquals(0, count($beansWithErrors));
//test the account has 3 opportunities
$account->forget();
$account = Account::getById($accountId);
$this->assertEquals(3, $account->opportunities->count());
}
示例10: testUpdateOpportunityFromForm
/**
* @depends testCreateAndGetOpportunityById
*/
public function testUpdateOpportunityFromForm()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = User::getByUsername('billy');
$opportunities = Opportunity::getByName('Test Opportunity');
$opportunity = $opportunities[0];
$this->assertEquals($opportunity->name, 'Test Opportunity');
$currencies = Currency::getAll();
$postData = array('owner' => array('id' => $user->id), 'name' => 'New Name', 'amount' => array('value' => '500.54', 'currency' => array('id' => $currencies[0]->id)), 'closeDate' => '2011-01-01', 'stage' => array('value' => 'Negotiating'));
$opportunity->setAttributes($postData);
$this->assertTrue($opportunity->save());
$id = $opportunity->id;
unset($opportunity);
$opportunity = Opportunity::getById($id);
$this->assertEquals('New Name', $opportunity->name);
$this->assertEquals(500.54, $opportunity->amount->value);
$this->assertEquals(1, $currencies[0]->rateToBase);
}
示例11: testKanbanViewForOpportunityDetails
public function testKanbanViewForOpportunityDetails()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$opportunities = Opportunity::getByName('superOpp');
$task = TaskTestHelper::createTaskWithOwnerAndRelatedItem('MyTask', $super, $opportunities[0], Task::STATUS_IN_PROGRESS);
$taskNew = TaskTestHelper::createTaskWithOwnerAndRelatedItem('MyTask New', $super, $opportunities[0], Task::STATUS_NEW);
$this->setGetArray(array('id' => $task->id, 'kanbanBoard' => '1'));
$content = $this->runControllerWithNoExceptionsAndGetContent('opportunities/default/details');
$matcher = array('tag' => 'h4', 'ancestor' => array('tag' => 'li', 'id' => 'items_' . $task->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-3'), 'content' => 'MyTask');
$this->assertTag($matcher, $content);
$matcher = array('tag' => 'h4', 'ancestor' => array('tag' => 'li', 'id' => 'items_' . $taskNew->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-1'), 'content' => 'MyTask New');
$this->assertTag($matcher, $content);
}
开发者ID:RamaKavanan,项目名称:BaseVersion,代码行数:13,代码来源:OpportunitiesSuperUserKanbanBoardWalkthroughTest.php