本文整理汇总了PHP中Account::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Account::deleteAll方法的具体用法?PHP Account::deleteAll怎么用?PHP Account::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account::deleteAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: teardown
public function teardown()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
Account::deleteAll();
parent::teardown();
}
示例2: testExportWithSelectAllForMoreThan10Records
public function testExportWithSelectAllForMoreThan10Records()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
Account::deleteAll();
ExportItem::deleteAll();
$numberOfRecords = rand(12, 100);
ExportModule::$asynchronousThreshold = $numberOfRecords - 1;
for ($i = 1; $i <= $numberOfRecords; $i++) {
$randomData = RandomDataUtil::getRandomDataByModuleAndModelClassNames('AccountsModule', 'Account');
AccountTestHelper::createAccountByNameForOwner($randomData['names'][$i], $super);
}
$this->setGetArray(array('Account_page' => '1', 'export' => '', 'selectAll' => '1', 'selectedIds' => '', 'ajax' => ''));
$this->runControllerWithRedirectExceptionAndGetUrl('accounts/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('accounts', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
for ($i = 1; $i <= $numberOfRecords; $i++) {
$this->assertContains($randomData['names'][$i], $fileModel->fileContent->content);
}
}
示例3: testBasicSearchAccounts
/**
* @depends testUnprivilegedUserViewUpdateDeleteAcounts
*/
public function testBasicSearchAccounts()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
Account::deleteAll();
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
AccountTestHelper::createAccountByNameTypeAndIndustryForOwner('First Account', 'Customer', 'Automotive', $super);
AccountTestHelper::createAccountByNameTypeAndIndustryForOwner('Second Account', 'Customer', 'Automotive', $super);
AccountTestHelper::createAccountByNameTypeAndIndustryForOwner('Third Account', 'Customer', 'Financial Services', $super);
AccountTestHelper::createAccountByNameTypeAndIndustryForOwner('Forth Account', 'Vendor', 'Financial Services', $super);
AccountTestHelper::createAccountByNameTypeAndIndustryForOwner('Fifth Account', 'Vendor', 'Financial Services', $super);
$searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('name' => ''), 'sort' => 'name');
$searchParamsQuery = http_build_query($searchParams);
$response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(3, count($response['data']['items']));
$this->assertEquals(5, $response['data']['totalCount']);
$this->assertEquals(1, $response['data']['currentPage']);
$this->assertEquals('Fifth Account', $response['data']['items'][0]['name']);
$this->assertEquals('First Account', $response['data']['items'][1]['name']);
$this->assertEquals('Forth Account', $response['data']['items'][2]['name']);
// Second page
$searchParams['pagination']['page'] = 2;
$searchParamsQuery = http_build_query($searchParams);
$response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(2, count($response['data']['items']));
$this->assertEquals(5, $response['data']['totalCount']);
$this->assertEquals(2, $response['data']['currentPage']);
$this->assertEquals('Second Account', $response['data']['items'][0]['name']);
$this->assertEquals('Third Account', $response['data']['items'][1]['name']);
// Search by name
$searchParams['pagination']['page'] = 1;
$searchParams['search']['name'] = 'First Account';
$searchParamsQuery = http_build_query($searchParams);
$response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(1, count($response['data']['items']));
$this->assertEquals(1, $response['data']['totalCount']);
$this->assertEquals(1, $response['data']['currentPage']);
$this->assertEquals('First Account', $response['data']['items'][0]['name']);
// No results
$searchParams['pagination']['page'] = 1;
$searchParams['search']['name'] = 'First Account 2';
$searchParamsQuery = http_build_query($searchParams);
$response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(0, $response['data']['totalCount']);
$this->assertFalse(isset($response['data']['items']));
// Search by name desc.
$searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('name' => ''), 'sort' => 'name.desc');
$searchParamsQuery = http_build_query($searchParams);
$response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(3, count($response['data']['items']));
$this->assertEquals(5, $response['data']['totalCount']);
$this->assertEquals(1, $response['data']['currentPage']);
$this->assertEquals('Third Account', $response['data']['items'][0]['name']);
$this->assertEquals('Second Account', $response['data']['items'][1]['name']);
$this->assertEquals('Forth Account', $response['data']['items'][2]['name']);
// Second page
$searchParams['pagination']['page'] = 2;
$searchParamsQuery = http_build_query($searchParams);
$response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(2, count($response['data']['items']));
$this->assertEquals(5, $response['data']['totalCount']);
$this->assertEquals(2, $response['data']['currentPage']);
$this->assertEquals('First Account', $response['data']['items'][0]['name']);
$this->assertEquals('Fifth Account', $response['data']['items'][1]['name']);
// Search by custom fields, order by name desc
$searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('industry' => array('value' => 'Financial Services'), 'type' => array('value' => 'Vendor'), 'owner' => array('id' => $super->id)), 'sort' => 'name.desc');
$searchParamsQuery = http_build_query($searchParams);
$response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
$this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
$this->assertEquals(2, $response['data']['totalCount']);
$this->assertEquals(2, count($response['data']['items']));
$this->assertEquals(1, $response['data']['currentPage']);
$this->assertEquals('Forth Account', $response['data']['items'][0]['name']);
$this->assertEquals('Fifth Account', $response['data']['items'][1]['name']);
}
示例4: testImportWithLatestActivityDateTime
public function testImportWithLatestActivityDateTime()
{
Yii::app()->user->userModel = User::getByUsername('super');
$accounts = Account::deleteAll();
$import = new Import();
$serializedData['importRulesType'] = 'Accounts';
$serializedData['firstRowIsHeaderRow'] = true;
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importWithLatestActivityDateTimeTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.accounts.tests.unit.files'));
$mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_1' => ImportMappingUtil::makeDateTimeColumnMappingData('latestActivityDateTime'));
$importRules = ImportRulesUtil::makeImportRulesByType('Accounts');
$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 2 models where created.
$accounts = Account::getAll();
$this->assertCount(2, $accounts);
$accounts = Account::getByName('company1');
$this->assertEquals('2011-12-22 05:03', substr($accounts[0]->latestActivityDateTime, 0, -3));
$accounts = Account::getByName('company2');
$this->assertNull($accounts[0]->latestActivityDateTime);
//Confirm 2 rows were processed as 'created'.
$this->assertEquals(2, 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 0 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));
}
示例5: testSuperUserConvertActionWithTagCloud
public function testSuperUserConvertActionWithTagCloud()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
Account::deleteAll();
DesignerTestHelper::createTagCloudAttribute('tagcloud', false, 'Account');
$this->setGetArray(array('moduleClassName' => 'AccountsModule', 'viewClassName' => 'AccountConvertToView'));
$layout = array('panels' => array(array('title' => 'Panel Title', 'panelDetailViewOnly' => 1, 'rows' => array(array('cells' => array(array('element' => 'name'))), array('cells' => array(array('element' => 'tagcloudCstm')))))));
$this->setPostArray(array('save' => 'Save', 'layout' => $layout));
$content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
$this->assertContains('Layout saved successfully', $content);
$lead = LeadTestHelper::createLeadbyNameForOwner('convertwithtagcloud', $super);
$this->setGetArray(array('id' => $lead->id));
$this->setPostArray(array('Account' => array('name' => 'mynewaccountfromleadtagcloudconvert', 'tagcloudCstm' => array('values' => 'English,French'))));
$this->assertEquals(0, Account::getCount());
$this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
$this->assertEquals(1, Account::getCount());
$accounts = Account::getAll();
$this->assertEquals('English, French', strval($accounts[0]->tagcloudCstm));
}
示例6: testUpdateReadSubscriptionTableForAllUsersAndModels
public function testUpdateReadSubscriptionTableForAllUsersAndModels()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$steven = User::getByUsername('steven');
$sql = "DELETE FROM account_read_subscription";
ZurmoRedBean::exec($sql);
$messageLogger = new DebuggingMessageLogger();
Account::deleteAll();
$account1 = AccountTestHelper::createAccountByNameForOwner('First Account', $super);
sleep(1);
$account2 = AccountTestHelper::createAccountByNameForOwner('First Account', $steven);
// Initial status is set to ReadPermissionsSubscriptionUtil::STATUS_STARTED
$this->assertEquals(ReadPermissionsSubscriptionUtil::STATUS_STARTED, ReadPermissionsSubscriptionUtil::getReadPermissionUpdateStatus());
$this->assertFalse(ReadPermissionsSubscriptionUtil::isReadPermissionSubscriptionUpdateCompleted());
ReadPermissionsSubscriptionUtil::updateAllReadSubscriptionTables($messageLogger);
$this->assertEquals(ReadPermissionsSubscriptionUtil::STATUS_COMPLETED, ReadPermissionsSubscriptionUtil::getReadPermissionUpdateStatus());
$this->assertTrue(ReadPermissionsSubscriptionUtil::isReadPermissionSubscriptionUpdateCompleted());
$sql = "SELECT * FROM account_read_subscription WHERE userid = " . $super->id;
$permissionTableRows = ZurmoRedBean::getAll($sql);
$this->assertEquals(2, count($permissionTableRows));
$this->assertEquals($account1->id, $permissionTableRows[0]['modelid']);
$this->assertEquals($super->id, $permissionTableRows[0]['userid']);
$this->assertEquals(ReadPermissionsSubscriptionUtil::TYPE_ADD, $permissionTableRows[0]['subscriptiontype']);
$this->assertEquals($account2->id, $permissionTableRows[1]['modelid']);
$this->assertEquals($super->id, $permissionTableRows[1]['userid']);
$this->assertEquals(ReadPermissionsSubscriptionUtil::TYPE_ADD, $permissionTableRows[1]['subscriptiontype']);
$sql = "SELECT * FROM account_read_subscription WHERE userid = " . $steven->id;
$permissionTableRows = ZurmoRedBean::getAll($sql);
$this->assertEquals(1, count($permissionTableRows));
$this->assertEquals($account2->id, $permissionTableRows[0]['modelid']);
$this->assertEquals($steven->id, $permissionTableRows[0]['userid']);
$this->assertEquals(ReadPermissionsSubscriptionUtil::TYPE_ADD, $permissionTableRows[0]['subscriptiontype']);
}