本文整理汇总了PHP中Contract::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Contract::getAll方法的具体用法?PHP Contract::getAll怎么用?PHP Contract::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contract
的用法示例。
在下文中一共展示了Contract::getAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
$contracts = Contract::getAll();
$this->assertEquals(0, count($contracts));
$import = new Import();
$serializedData['importRulesType'] = 'Contracts';
$serializedData['firstRowIsHeaderRow'] = true;
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importTestIncludingRateAndCurrencyCode.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.contracts.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('Contracts');
$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.
$contracts = Contract::getAll();
$this->assertEquals(3, count($contracts));
$contracts = Contract::getByName('opp1');
$this->assertEquals(1, count($contracts[0]));
$this->assertEquals('opp1', $contracts[0]->name);
$this->assertEquals('1980-06-03', $contracts[0]->closeDate);
$this->assertEquals(10, $contracts[0]->probability);
$this->assertEquals('desc1', $contracts[0]->description);
$this->assertTrue($contracts[0]->account->isSame($account));
$this->assertEquals('Prospecting', $contracts[0]->stage->value);
$this->assertEquals('Self-Generated', $contracts[0]->source->value);
$this->assertEquals(500, $contracts[0]->amount->value);
$this->assertEquals(1, $contracts[0]->amount->rateToBase);
$this->assertEquals('USD', $contracts[0]->amount->currency->code);
$contracts = Contract::getByName('opp2');
$this->assertEquals(1, count($contracts[0]));
$this->assertEquals('opp2', $contracts[0]->name);
$this->assertEquals('1980-06-04', $contracts[0]->closeDate);
$this->assertEquals(25, $contracts[0]->probability);
$this->assertEquals('desc2', $contracts[0]->description);
$this->assertTrue($contracts[0]->account->isSame($account));
$this->assertEquals('Qualification', $contracts[0]->stage->value);
$this->assertEquals('Inbound Call', $contracts[0]->source->value);
$this->assertEquals(501, $contracts[0]->amount->value);
// $this->assertEquals(2.7, $contracts[0]->amount->rateToBase);
$this->assertEquals('GBP', $contracts[0]->amount->currency->code);
$contracts = Contract::getByName('opp3');
$this->assertEquals(1, count($contracts[0]));
$this->assertEquals('opp3', $contracts[0]->name);
$this->assertEquals('1980-06-05', $contracts[0]->closeDate);
$this->assertEquals(50, $contracts[0]->probability);
$this->assertEquals('desc3', $contracts[0]->description);
$this->assertTrue($contracts[0]->account->isSame($account));
$this->assertEquals('Negotiating', $contracts[0]->stage->value);
$this->assertEquals('Tradeshow', $contracts[0]->source->value);
$this->assertEquals(502, $contracts[0]->amount->value);
// $this->assertEquals(3.2, $contracts[0]->amount->rateToBase);
$this->assertEquals('EUR', $contracts[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 contracts
$account->forget();
$account = Account::getById($accountId);
$this->assertEquals(3, $account->contracts->count());
}
示例2: testAsynchronousDownloadDefaultControllerActions
/**
* Walkthrough test for synchronous download
*/
public function testAsynchronousDownloadDefaultControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$account = AccountTestHelper::createAccountByNameForOwner('superAccount2', $super);
$notificationsBeforeCount = Notification::getCount();
$notificationMessagesBeforeCount = NotificationMessage::getCount();
$contracts = Contract::getAll();
if (count($contracts)) {
foreach ($contracts as $contract) {
$contract->delete();
}
}
$contracts = array();
for ($i = 0; $i <= ExportModule::$asynchronousThreshold + 1; $i++) {
$contracts[] = ContractTestHelper::createContractWithAccountByNameForOwner('contract' . $i, $super, $account);
}
$this->setGetArray(array('Contract_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
$this->runControllerWithRedirectExceptionAndGetUrl('contracts/default/export');
// Start background job
$job = new ExportJob();
$this->assertTrue($job->run());
$exportItems = ExportItem::getAll();
$this->assertEquals(1, count($exportItems));
$fileModel = $exportItems[0]->exportFileModel;
$this->assertEquals(1, $exportItems[0]->isCompleted);
$this->assertEquals('csv', $exportItems[0]->exportFileType);
$this->assertEquals('contracts', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
$this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
// Check export job, when many ids are selected.
// This will probably never happen, but we need test for this case too.
$notificationsBeforeCount = Notification::getCount();
$notificationMessagesBeforeCount = NotificationMessage::getCount();
// Now test case when multiple ids are selected
$exportItems = ExportItem::getAll();
if (count($exportItems)) {
foreach ($exportItems as $exportItem) {
$exportItem->delete();
}
}
$selectedIds = "";
foreach ($contracts as $contract) {
$selectedIds .= $contract->id . ",";
// Not Coding Standard
}
$this->setGetArray(array('ContractsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'name' => '', 'officePhone' => ''), 'Contract_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$selectedIds}"));
$this->runControllerWithRedirectExceptionAndGetUrl('contracts/default/export');
// Start background job
$job = new ExportJob();
$this->assertTrue($job->run());
$exportItems = ExportItem::getAll();
$this->assertEquals(1, count($exportItems));
$fileModel = $exportItems[0]->exportFileModel;
$this->assertEquals(1, $exportItems[0]->isCompleted);
$this->assertEquals('csv', $exportItems[0]->exportFileType);
$this->assertEquals('contracts', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
$this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
}
示例3: testGetAllWhenThereAreNone
public function testGetAllWhenThereAreNone()
{
Yii::app()->user->userModel = User::getByUsername('super');
$contracts = Contract::getAll();
$this->assertEquals(0, count($contracts));
}
示例4: testRegularMassDeletePagesProperlyAndRemovesAllSelected
/**
*Test Bug with mass delete and multiple pages when using select all
*/
public function testRegularMassDeletePagesProperlyAndRemovesAllSelected()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$confused = User::getByUsername('confused');
$nobody = User::getByUsername('nobody');
//Load MassDelete view for the 8 contracts.
$contracts = Contract::getAll();
$this->assertEquals(9, count($contracts));
//Deleting all contracts
//mass Delete pagination scenario
//Run Mass Delete using progress save for page1
$this->setGetArray(array('selectAll' => '1', 'Contract_page' => 1));
$this->setPostArray(array('selectedRecordCount' => 9));
$pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
$this->assertEquals(5, $pageSize);
$content = $this->runControllerWithExitExceptionAndGetContent('contracts/default/massDelete');
$contracts = Contract::getAll();
$this->assertEquals(4, count($contracts));
//Run Mass Delete using progress save for page2
$this->setGetArray(array('selectAll' => '1', 'Contract_page' => 2));
$this->setPostArray(array('selectedRecordCount' => 9));
$pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
$this->assertEquals(5, $pageSize);
$content = $this->runControllerWithNoExceptionsAndGetContent('contracts/default/massDeleteProgress');
$contracts = Contract::getAll();
$this->assertEquals(0, count($contracts));
}
示例5: testMassDeletePagesProperlyAndRemovesAllSelected
/**
*Test Bug with mass delete and multiple pages when using select all
*/
public function testMassDeletePagesProperlyAndRemovesAllSelected()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//MassDelete for selected Record Count
$Contracts = Contract::getAll();
$this->assertEquals(8, count($Contracts));
$pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
$this->assertEquals(5, $pageSize);
//save Model MassDelete for entire search result
$this->setGetArray(array('selectAll' => '1', 'Contract_page' => 1));
$this->setPostArray(array('selectedRecordCount' => 8));
//Run Mass Delete using progress save for page1.
$this->runControllerWithExitExceptionAndGetContent('contracts/default/massDelete');
//check for previous mass delete progress
$Contracts = Contract::getAll();
$this->assertEquals(3, count($Contracts));
$this->setGetArray(array('selectAll' => '1', 'Contract_page' => 2));
$this->setPostArray(array('selectedRecordCount' => 8));
//Run Mass Delete using progress save for page2.
$pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
$this->assertEquals(5, $pageSize);
$this->runControllerWithNoExceptionsAndGetContent('contracts/default/massDeleteProgress');
//calculating lead's count
$Contracts = Contract::getAll();
$this->assertEquals(0, count($Contracts));
}