public function testProperlyDeletingActivityItems() { Yii::app()->user->userModel = User::getByUsername('super'); $count = ZurmoRedBean::getRow('select count(*) count from activity_item'); $this->assertEquals(0, $count['count']); $account = AccountTestHelper::createAccountByNameForOwner('anAccount', Yii::app()->user->userModel); $deleted = $account->delete(); $this->assertTrue($deleted); $count = ZurmoRedBean::getRow('select count(*) count from activity_item'); $this->assertEquals(0, $count['count']); $account2 = AccountTestHelper::createAccountByNameForOwner('anAccount2', Yii::app()->user->userModel); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('anOpp', Yii::app()->user->userModel); $task = TaskTestHelper::createTaskWithOwnerAndRelatedAccount('aTask', Yii::app()->user->userModel, $account2); $task->activityItems->add($opportunity); $this->assertTrue($task->save()); $taskId = $task->id; $task->forget(); RedBeansCache::forgetAll(); $count = ZurmoRedBean::getRow('select count(*) count from activity_item'); $this->assertEquals(2, $count['count']); $deleted = $account2->delete(); $this->assertTrue($deleted); $account2->forget(); $count = ZurmoRedBean::getRow('select count(*) count from activity_item'); $this->assertEquals(1, $count['count']); RedBeansCache::forgetAll(); //Make sure things render ok even with the account deleted. $content = ActivitiesUtil::renderSummaryContent(Task::getById($taskId), 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'HomeModule'); }
public function testDownCasts() { $possibleDerivationPaths = array(array('SecurableItem', 'OwnedSecurableItem', 'Account'), array('SecurableItem', 'OwnedSecurableItem', 'Person', 'Contact'), array('SecurableItem', 'OwnedSecurableItem', 'Opportunity')); $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $account = AccountTestHelper::createAccountByNameForOwner('Waggle', $super); $contact = ContactTestHelper::createContactByNameForOwner('Noddy', $super); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('Noddy', $super); $accountItem = Item::getById($account->getClassId('Item')); $contactItem = Item::getById($contact->getClassId('Item')); $opportunityItem = Item::getById($opportunity->getClassId('Item')); $this->assertTrue($accountItem->isSame($account)); $this->assertTrue($contactItem->isSame($contact)); $this->assertTrue($opportunityItem->isSame($opportunity)); $this->assertFalse($accountItem instanceof Account); $this->assertFalse($contactItem instanceof Contact); $this->assertFalse($opportunityItem instanceof Opportunity); $account2 = $accountItem->castDown($possibleDerivationPaths); $this->assertEquals('Account', get_class($account2)); //Demonstrate a single array, making sure it casts down properly. $accountItem2 = Item::getById($account->getClassId('Item')); $account3 = $accountItem2->castDown(array(array('SecurableItem', 'OwnedSecurableItem', 'Account'))); $this->assertEquals('Account', get_class($account3)); $contact2 = $contactItem->castDown($possibleDerivationPaths); $opportunity2 = $opportunityItem->castDown($possibleDerivationPaths); $this->assertTrue($account2->isSame($account)); $this->assertTrue($contact2->isSame($contact)); $this->assertTrue($opportunity2->isSame($opportunity)); $this->assertTrue($account2 instanceof Account); $this->assertTrue($contact2 instanceof Contact); $this->assertTrue($opportunity2 instanceof Opportunity); $account2 = AccountTestHelper::createAccountByNameForOwner('Waggle2', $super); //By adding a second contact with a relation to the account2, we can demonstrate a bug with how castDown works. //Since contacts can in fact be attached to accounts via account_id, if a contact exists connected to the account //we are trying to cast down, then this will cast down even though it shouldn't. $contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('MrWaggle2', $super, $account2); try { $account2CastedDown = $account2->castDown(array(array('SecurableItem', 'OwnedSecurableItem', 'Person', 'Contact'))); $this->fail(); } catch (NotFoundException $e) { //success } //Now try to forget the account and retrieve it. $account2Id = $account2->id; $account2->forget(); unset($account2); $account2 = Account::getById($account2Id); try { $account2CastedDown = $account2->castDown(array(array('SecurableItem', 'OwnedSecurableItem', 'Person', 'Contact'))); $this->fail(); } catch (NotFoundException $e) { //success } }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); SecurityTestHelper::createSuperAdmin(); $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; //Setup test data owned by the super user. $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('superOpportunity', $super); $productTemplate = ProductTemplateTestHelper::createProductTemplateByName('superProductTemplate'); $contactWithNoAccount = ContactTestHelper::createContactByNameForOwner('noAccountContact', $super); }
public function testCopy() { Yii::app()->user->userModel = User::getByUsername('super'); $user = Yii::app()->user->userModel; $project = new Project(); $project->name = 'Project 1'; $project->owner = $user; $project->description = 'Description'; $user = UserTestHelper::createBasicUser('Steven'); $account = new Account(); $account->owner = $user; $account->name = DataUtil::purifyHtml("Tom & Jerry's Account"); $this->assertTrue($account->save()); $id = $account->id; unset($account); $account = Account::getById($id); $this->assertEquals("Tom & Jerry's Account", $account->name); $contact = ContactTestHelper::createContactByNameForOwner('Jerry', $user); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('Jerry Opp', $user); $this->assertTrue($project->save()); $this->assertEquals(1, count($project->auditEvents)); $id = $project->id; $project->forget(); unset($project); $project = Project::getById($id); ProjectZurmoControllerUtil::resolveProjectManyManyAccountsFromPost($project, array('accountIds' => $account->id)); ProjectZurmoControllerUtil::resolveProjectManyManyContactsFromPost($project, array('contactIds' => $contact->id)); ProjectZurmoControllerUtil::resolveProjectManyManyOpportunitiesFromPost($project, array('opportunityIds' => $opportunity->id)); $this->assertEquals('Project 1', $project->name); $this->assertEquals('Description', $project->description); $this->assertEquals(1, $project->accounts->count()); $this->assertEquals(1, $project->contacts->count()); $this->assertEquals(1, $project->opportunities->count()); $task = TaskTestHelper::createTaskByNameWithProjectAndStatus('MyFirstKanbanTask', Yii::app()->user->userModel, $project, Task::STATUS_IN_PROGRESS); $kanbanItem1 = KanbanItem::getByTask($task->id); $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem1->type); $this->assertEquals($task->project->id, $kanbanItem1->kanbanRelatedItem->id); $copyToProject = new Project(); ProjectZurmoCopyModelUtil::copy($project, $copyToProject); ProjectZurmoCopyModelUtil::processAfterCopy($project, $copyToProject); $this->assertTrue($copyToProject->save()); $this->assertEquals($copyToProject->name, $project->name); $this->assertEquals($copyToProject->description, $project->description); $this->assertEquals($copyToProject->status, $project->status); $project = Project::getByName('Project 1'); $this->assertEquals(2, count($project)); $tasks = Task::getAll(); $this->assertEquals(2, count($tasks)); }
public function testImportDataAnalysisResults() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $import = new Import(); $serializedData['importRulesType'] = 'Tasks'; $import->serializedData = serialize($serializedData); $this->assertTrue($import->save()); $accountTableName = Account::getTableName('Account'); $contactTableName = Contact::getTableName('Contact'); $opportunityTableName = Opportunity::getTableName('Opportunity'); $account1 = AccountTestHelper::createAccountByNameForOwner('account1', $super); $account2 = AccountTestHelper::createAccountByNameForOwner('account2', $super); $account3 = AccountTestHelper::createAccountByNameForOwner('account3', $super); $contact1 = ContactTestHelper::createContactByNameForOwner('contact1', $super); $contact2 = ContactTestHelper::createContactByNameForOwner('contact2', $super); $contact3 = ContactTestHelper::createContactByNameForOwner('contact3', $super); $opportunity1 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity1', $super); $opportunity2 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity2', $super); $opportunity3 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity3', $super); //Make models externally linked for testing. ImportTestHelper::updateModelsExternalId($account2, 'ACC'); ImportTestHelper::updateModelsExternalId($contact2, 'CON'); ImportTestHelper::updateModelsExternalId($opportunity2, 'OPP'); ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.tasks.tests.unit.files')); R::exec("update " . $import->getTempTableName() . " set column_0 = " . $account3->id . " where id != 1 limit 3"); R::exec("update " . $import->getTempTableName() . " set column_2 = " . $contact3->id . " where id != 1 limit 4"); R::exec("update " . $import->getTempTableName() . " set column_4 = " . $opportunity3->id . " where id != 1 limit 5"); $mappingData = array('column_0' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_1' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived'), 'column_2' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_3' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived'), 'column_4' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_5' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived')); $serializedData = unserialize($import->serializedData); $serializedData['mappingData'] = $mappingData; $import->serializedData = serialize($serializedData); $this->assertTrue($import->save()); $importRules = ImportRulesUtil::makeImportRulesByType('Tasks'); $config = array('pagination' => array('pageSize' => 2)); //This test csv has a header row. $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config); //Run data analyzer $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider); foreach ($mappingData as $columnName => $columnMappingData) { $importDataAnalyzer->analyzeByColumnNameAndColumnMappingData($columnName, $columnMappingData); } $messagesData = $importDataAnalyzer->getMessagesData(); $compareData = array('column_0' => array(array('message' => '3 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'AccountDerivedIdValueType', 'moreAvailable' => false)), 'column_1' => array(array('message' => '3 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'AccountDerivedIdValueType', 'moreAvailable' => false)), 'column_2' => array(array('message' => '4 record(s) will be updated and 6 record(s) will be skipped during import.', 'sanitizerUtilType' => 'ContactDerivedIdValueType', 'moreAvailable' => false)), 'column_3' => array(array('message' => '3 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'ContactDerivedIdValueType', 'moreAvailable' => false)), 'column_4' => array(array('message' => '5 record(s) will be updated and 5 record(s) will be skipped during import.', 'sanitizerUtilType' => 'OpportunityDerivedIdValueType', 'moreAvailable' => false)), 'column_5' => array(array('message' => '3 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'OpportunityDerivedIdValueType', 'moreAvailable' => false))); $this->assertEquals($compareData, $messagesData); $importInstructionsData = $importDataAnalyzer->getImportInstructionsData(); $compareInstructionsData = array(); $this->assertEquals($compareInstructionsData, $importInstructionsData); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); $super = SecurityTestHelper::createSuperAdmin(); Yii::app()->user->userModel = $super; ExternalSystemIdUtil::addExternalIdColumnIfMissing(Account::getTableName()); ExternalSystemIdUtil::addExternalIdColumnIfMissing(Contact::getTableName()); ExternalSystemIdUtil::addExternalIdColumnIfMissing(Opportunity::getTableName()); $account = AccountTestHelper::createAccountByNameForOwner('testAccount', $super); ImportTestHelper::updateModelsExternalId($account, 'ACC'); $contact = ContactTestHelper::createContactByNameForOwner('testContact', $super); ImportTestHelper::updateModelsExternalId($contact, 'CON'); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('testOpportunity', $super); ImportTestHelper::updateModelsExternalId($opportunity, 'OPP'); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); SecurityTestHelper::createSuperAdmin(); $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; //Setup test data owned by the super user. $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super); OpportunityTestHelper::createOpportunityStagesIfDoesNotExist(); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('superOpportunity', $super); $productTemplate = ProductTemplateTestHelper::createProductTemplateByName('superProductTemplate'); $contactWithNoAccount = ContactTestHelper::createContactByNameForOwner('noAccountContact', $super); $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); $everyoneGroup->save(); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); $super = SecurityTestHelper::createSuperAdmin(); Yii::app()->user->userModel = $super; $columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME; RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem::getTableName('Account'), $columnName); RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem2::getTableName('Contact'), $columnName); RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem3::getTableName('Opportunity'), $columnName); $account = AccountTestHelper::createAccountByNameForOwner('testAccount', $super); ImportTestHelper::updateModelsExternalId($account, 'ACC'); $contact = ContactTestHelper::createContactByNameForOwner('testContact', $super); ImportTestHelper::updateModelsExternalId($contact, 'CON'); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('testOpportunity', $super); ImportTestHelper::updateModelsExternalId($opportunity, 'OPP'); }
public function testCreateAndGetProjectById() { Yii::app()->user->userModel = User::getByUsername('super'); $user = Yii::app()->user->userModel; $project = new Project(); $project->name = 'Project 1'; $project->owner = $user; $project->description = 'Description'; $user = UserTestHelper::createBasicUser('Steven'); $account = new Account(); $account->owner = $user; $account->name = DataUtil::purifyHtml("Tom & Jerry's Account"); $this->assertTrue($account->save()); $id = $account->id; unset($account); $account = Account::getById($id); $this->assertEquals("Tom & Jerry's Account", $account->name); //$project->accounts->add($account); $contact = ContactTestHelper::createContactByNameForOwner('Jerry', $user); //$project->contacts->add($contact); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('Jerry Opp', $user); //$project->opportunities->add($opportunity); $this->assertTrue($project->save()); $this->assertEquals(1, count($project->auditEvents)); $id = $project->id; $project->forget(); unset($project); $project = Project::getById($id); ProjectZurmoControllerUtil::resolveProjectManyManyAccountsFromPost($project, array('accountIds' => $account->id)); ProjectZurmoControllerUtil::resolveProjectManyManyContactsFromPost($project, array('contactIds' => $contact->id)); ProjectZurmoControllerUtil::resolveProjectManyManyOpportunitiesFromPost($project, array('opportunityIds' => $opportunity->id)); $this->assertEquals('Project 1', $project->name); $this->assertEquals('Description', $project->description); $this->assertEquals(1, $project->accounts->count()); $this->assertEquals(1, $project->contacts->count()); $this->assertEquals(1, $project->opportunities->count()); //Try saving a second project $project = new Project(); $project->name = 'Project 2'; $project->owner = $user; $project->description = 'Description'; $this->assertTrue($project->save()); $this->assertEquals(1, count($project->auditEvents)); }
public function testEditOpportunityWIthIncorrectDataType() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $authenticationData = $this->login(); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('Newest Opportunity', $super); // Provide data with wrong type. $data['probability'] = str_repeat('a', 128); $response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals(5, count($response['errors'])); $id = $opportunity->id; $data = array(); $data['name'] = str_repeat('a', 128); $response = $this->createApiCallWithRelativeUrl('update/' . $id, 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']); $this->assertEquals(1, count($response['errors'])); }
private function addOpportunity() { $primaryModel = $this->getPrimaryModel(); $this->assertEquals(0, count($primaryModel->opportunities)); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('UI Services', Yii::app()->user->userModel); $opportunity->account = $this->selectedModels[1]; $opportunity->save(); }
public function testCreateARelatedContactOnAnOpportunityWhenOpportunityBecomesClosedWon() { $super = User::getByUsername('super'); $contactStates = ContactState::getAll(); //Create workflow $workflow = new Workflow(); $workflow->setDescription('aDescription'); $workflow->setIsActive(true); $workflow->setOrder(1); $workflow->setModuleClassName('OpportunitiesModule'); $workflow->setName('myFirstWorkflow'); $workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING); $workflow->setType(Workflow::TYPE_ON_SAVE); $workflow->setTriggersStructure('1'); //Add Trigger $trigger = new TriggerForWorkflowForm('OpportunitiesModule', 'Opportunity', Workflow::TYPE_ON_SAVE); $trigger->attributeIndexOrDerivedType = 'stage'; $trigger->value = 'Prospecting'; $trigger->operator = 'equals'; $workflow->addTrigger($trigger); //Add action $action = new ActionForWorkflowForm('Opportunity', Workflow::TYPE_ON_SAVE); $action->type = ActionForWorkflowForm::TYPE_CREATE; $action->relation = 'contacts'; $attributes = array('lastName' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'smith'), 'firstName' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'john'), 'owner__User' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => Yii::app()->user->userModel->id), 'state' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => $contactStates[0]->id)); $action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes)); $workflow->addAction($action); //Create the saved Workflow $savedWorkflow = new SavedWorkflow(); SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow); $saved = $savedWorkflow->save(); $this->assertTrue($saved); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('some opp', $super); $this->assertTrue($opportunity->id > 0); $this->assertEquals(0, $opportunity->contacts->count()); //Change opportunity to Prospecting $opportunity->stage->value = 'Prospecting'; $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $opportunity)); $saved = $opportunity->save(); $this->assertTrue($saved); $this->assertEquals(1, $opportunity->contacts->count()); $this->assertEquals('smith', $opportunity->contacts[0]->lastName); }
/** * @depends testCreateWithRelations */ public function testUpdateWithRelations() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $authenticationData = $this->login(); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $contact = ContactTestHelper::createContactByNameForOwner('Simon', $super); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('My Opportunity', $super); $compareData = $this->getModelToApiDataUtilData($contact); $contact->forget(); $data['modelRelations'] = array('opportunities' => array(array('action' => 'add', 'modelId' => $opportunity->id, 'modelClassName' => 'Opportunity'))); $data['firstName'] = 'Fred'; $response = $this->createApiCallWithRelativeUrl('update/' . $compareData['id'], 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); unset($response['data']['modifiedDateTime']); unset($compareData['modifiedDateTime']); $compareData['firstName'] = 'Fred'; $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $this->assertEquals($compareData, $response['data']); RedBeanModel::forgetAll(); $contact = Contact::getById($compareData['id']); $this->assertEquals(1, count($contact->opportunities)); $this->assertEquals($opportunity->id, $contact->opportunities[0]->id); $opportunity = Opportunity::getById($opportunity->id); $this->assertEquals(1, count($opportunity->contacts)); $this->assertEquals($contact->id, $opportunity->contacts[0]->id); // Now test remove relations $data['modelRelations'] = array('opportunities' => array(array('action' => 'remove', 'modelId' => $opportunity->id, 'modelClassName' => 'Opportunity'))); $response = $this->createApiCallWithRelativeUrl('update/' . $compareData['id'], 'PUT', $headers, array('data' => $data)); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); RedBeanModel::forgetAll(); $contact = Contact::getById($compareData['id']); $this->assertEquals(0, count($contact->opportunities)); $opportunity = Opportunity::getById($opportunity->id); $this->assertEquals(0, count($opportunity->contacts)); }
public function testGetMeetingWithAttendees() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $evelina = UserTestHelper::createBasicUser('Evelina'); $amelia = UserTestHelper::createBasicUser('Amelia'); $amelia->primaryEmail->emailAddress = '*****@*****.**'; $this->assertTrue($amelia->save()); $contact1 = ContactTestHelper::createContactByNameForOwner('TestContact3', $super); $contact2 = ContactTestHelper::createContactByNameForOwner('TestContact4', $super); $contact2->primaryEmail->emailAddress = '*****@*****.**'; $this->assertTrue($contact2->save()); $authenticationData = $this->login(); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $meeting = MeetingTestHelper::createMeetingByNameForOwner('Meeting 2 With User Attendees', $super); $response = $this->createApiCallWithRelativeUrl('read/?id=' . $meeting->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $this->assertTrue(isset($response['data']['attendees'])); $this->assertTrue(isset($response['data']['attendees']['Organizer'])); $this->assertEquals($super->id, $response['data']['attendees']['Organizer']['id']); $this->assertEquals($super->firstName, $response['data']['attendees']['Organizer']['firstName']); $this->assertEquals($super->lastName, $response['data']['attendees']['Organizer']['lastName']); $this->assertEquals($super->username, $response['data']['attendees']['Organizer']['username']); $this->assertFalse(isset($response['data']['attendees']['Organizer']['email'])); $meeting->activityItems->add($contact1); $meeting->activityItems->add($contact2); $this->assertTrue($meeting->save()); $response = $this->createApiCallWithRelativeUrl('read/?id=' . $meeting->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $this->assertEquals(2, count($response['data']['attendees']['Contact'])); $this->assertEquals($contact1->id, $response['data']['attendees']['Contact'][0]['id']); $this->assertEquals($contact1->firstName, $response['data']['attendees']['Contact'][0]['firstName']); $this->assertEquals($contact1->lastName, $response['data']['attendees']['Contact'][0]['lastName']); $this->assertEquals($contact2->id, $response['data']['attendees']['Contact'][1]['id']); $this->assertEquals($contact2->firstName, $response['data']['attendees']['Contact'][1]['firstName']); $this->assertEquals($contact2->lastName, $response['data']['attendees']['Contact'][1]['lastName']); $this->assertEquals($contact2->primaryEmail->emailAddress, $response['data']['attendees']['Contact'][1]['email']); $meeting->userAttendees->add($evelina); $meeting->userAttendees->add($amelia); $this->assertTrue($meeting->save()); $response = $this->createApiCallWithRelativeUrl('read/?id=' . $meeting->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $this->assertEquals(2, count($response['data']['attendees']['Contact'])); $this->assertEquals($contact1->id, $response['data']['attendees']['Contact'][0]['id']); $this->assertEquals($contact1->firstName, $response['data']['attendees']['Contact'][0]['firstName']); $this->assertEquals($contact1->lastName, $response['data']['attendees']['Contact'][0]['lastName']); $this->assertEquals($contact2->id, $response['data']['attendees']['Contact'][1]['id']); $this->assertEquals($contact2->firstName, $response['data']['attendees']['Contact'][1]['firstName']); $this->assertEquals($contact2->lastName, $response['data']['attendees']['Contact'][1]['lastName']); $this->assertEquals(2, count($response['data']['attendees']['User'])); $this->assertEquals($evelina->id, $response['data']['attendees']['User'][0]['id']); $this->assertEquals($evelina->firstName, $response['data']['attendees']['User'][0]['firstName']); $this->assertEquals($evelina->lastName, $response['data']['attendees']['User'][0]['lastName']); $this->assertEquals($evelina->username, $response['data']['attendees']['User'][0]['username']); $this->assertEquals($amelia->id, $response['data']['attendees']['User'][1]['id']); $this->assertEquals($amelia->primaryEmail->emailAddress, $response['data']['attendees']['User'][1]['email']); $this->assertEquals($amelia->firstName, $response['data']['attendees']['User'][1]['firstName']); $this->assertEquals($amelia->lastName, $response['data']['attendees']['User'][1]['lastName']); $this->assertEquals($amelia->username, $response['data']['attendees']['User'][1]['username']); $this->assertTrue(isset($response['data']['attendees']['Organizer'])); $this->assertEquals($super->id, $response['data']['attendees']['Organizer']['id']); $this->assertEquals($super->firstName, $response['data']['attendees']['Organizer']['firstName']); $this->assertEquals($super->lastName, $response['data']['attendees']['Organizer']['lastName']); $this->assertEquals($super->username, $response['data']['attendees']['Organizer']['username']); // Test with opportunity and account activity items $account = AccountTestHelper::createAccountByNameForOwner('Account 2', $super); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('TestOpportunity 2', $super); $meeting2 = MeetingTestHelper::createMeetingByNameForOwner('Meeting 3 With Account and Opportunity', $super); $meeting2->activityItems->add($account); $meeting2->activityItems->add($opportunity); $this->assertTrue($meeting2->save()); $searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('name' => 'Meeting 3 With Account and Opportunity'), 'sort' => 'name'); $searchParamsQuery = http_build_query($searchParams); $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(1, count($response['data']['items'])); $this->assertEquals($account->id, $response['data']['items'][0]['attendees']['Account'][0]['id']); $this->assertEquals($account->name, $response['data']['items'][0]['attendees']['Account'][0]['name']); $this->assertEquals($opportunity->id, $response['data']['items'][0]['attendees']['Opportunity'][0]['id']); $this->assertEquals($opportunity->name, $response['data']['items'][0]['attendees']['Opportunity'][0]['name']); // Test with regular user if he can get user attendees $michael = UserTestHelper::createBasicUser('Michael'); $michael->primaryEmail->emailAddress = '*****@*****.**'; $this->assertTrue($michael->save()); $michael->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API); $michael->setRight('MeetingsModule', MeetingsModule::getAccessRight()); $michael->setRight('MeetingsModule', MeetingsModule::getCreateRight()); $saved = $michael->save(); $this->assertTrue($saved); $michaelMeeting = MeetingTestHelper::createMeetingByNameForOwner('Meeting 4 With User', $michael); $michaelMeeting->userAttendees->add($evelina); $this->assertTrue($michaelMeeting->save()); $authenticationData = $this->login('michael', 'michael'); $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST'); $response = $this->createApiCallWithRelativeUrl('read/?id=' . $michaelMeeting->id, 'GET', $headers); $response = json_decode($response, true); $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']); $this->assertEquals(1, count($response['data']['attendees']['User'])); $this->assertEquals($evelina->id, $response['data']['attendees']['User'][0]['id']); $this->assertEquals($evelina->firstName, $response['data']['attendees']['User'][0]['firstName']); $this->assertEquals($evelina->lastName, $response['data']['attendees']['User'][0]['lastName']); $this->assertEquals($evelina->username, $response['data']['attendees']['User'][0]['username']); $this->assertTrue(isset($response['data']['attendees']['Organizer'])); $this->assertEquals($michael->id, $response['data']['attendees']['Organizer']['id']); $this->assertEquals($michael->firstName, $response['data']['attendees']['Organizer']['firstName']); $this->assertEquals($michael->lastName, $response['data']['attendees']['Organizer']['lastName']); $this->assertEquals($michael->username, $response['data']['attendees']['Organizer']['username']); $this->assertEquals($michael->primaryEmail->emailAddress, $response['data']['attendees']['Organizer']['email']); }
public function testImportDataAnalysisResults() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $import = new Import(); $serializedData['importRulesType'] = 'Tasks'; $import->serializedData = serialize($serializedData); $this->assertTrue($import->save()); $account1 = AccountTestHelper::createAccountByNameForOwner('account1', $super); $account2 = AccountTestHelper::createAccountByNameForOwner('account2', $super); $account3 = AccountTestHelper::createAccountByNameForOwner('account3', $super); $contact1 = ContactTestHelper::createContactByNameForOwner('contact1', $super); $contact2 = ContactTestHelper::createContactByNameForOwner('contact2', $super); $contact3 = ContactTestHelper::createContactByNameForOwner('contact3', $super); $opportunity1 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity1', $super); $opportunity2 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity2', $super); $opportunity3 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity3', $super); //Make models externally linked for testing. ImportTestHelper::updateModelsExternalId($account2, 'ACC'); ImportTestHelper::updateModelsExternalId($contact2, 'CON'); ImportTestHelper::updateModelsExternalId($opportunity2, 'OPP'); ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.tasks.tests.unit.files')); ZurmoRedBean::exec("update " . $import->getTempTableName() . " set column_0 = " . $account3->id . " where id != 1 limit 3"); ZurmoRedBean::exec("update " . $import->getTempTableName() . " set column_2 = " . $contact3->id . " where id != 1 limit 4"); ZurmoRedBean::exec("update " . $import->getTempTableName() . " set column_4 = " . $opportunity3->id . " where id != 1 limit 5"); $mappingData = array('column_0' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_1' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived'), 'column_2' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_3' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived'), 'column_4' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_5' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived'), 'column_6' => ImportMappingUtil::makeIntegerColumnMappingData('status')); $serializedData = unserialize($import->serializedData); $serializedData['mappingData'] = $mappingData; $import->serializedData = serialize($serializedData); $this->assertTrue($import->save()); $importRules = ImportRulesUtil::makeImportRulesByType('Tasks'); $config = array('pagination' => array('pageSize' => 15)); //This test csv has a header row. $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config); //Run data analyzer $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider, $mappingData, array('column_0', 'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6')); $importDataAnalyzer->analyzePage(); $data = $dataProvider->getData(); $this->assertEquals(10, count($data)); $compareData = array(); $compareData['column_0'][] = 'Is an existing record and will be updated.'; $compareData['column_1'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_2'][] = 'Is an existing record and will be updated.'; $compareData['column_3'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_4'][] = 'Is an existing record and will be updated.'; $compareData['column_5'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $this->assertEquals($compareData, unserialize($data[0]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[0]->analysisStatus); $compareData = array(); $compareData['column_0'][] = 'Is an existing record and will be updated.'; $compareData['column_1'][] = 'Is an existing record and will be updated.'; $compareData['column_2'][] = 'Is an existing record and will be updated.'; $compareData['column_3'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_4'][] = 'Is an existing record and will be updated.'; $compareData['column_5'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $this->assertEquals($compareData, unserialize($data[1]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[1]->analysisStatus); $compareData = array(); $compareData['column_0'][] = 'Is an existing record and will be updated.'; $compareData['column_1'][] = 'Is an existing record and will be updated.'; $compareData['column_2'][] = 'Is an existing record and will be updated.'; $compareData['column_3'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_4'][] = 'Is an existing record and will be updated.'; $compareData['column_5'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $this->assertEquals($compareData, unserialize($data[2]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[2]->analysisStatus); $compareData = array(); $compareData['column_0'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_1'][] = 'Is an existing record and will be updated.'; $compareData['column_2'][] = 'Is an existing record and will be updated.'; $compareData['column_3'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_4'][] = 'Is an existing record and will be updated.'; $compareData['column_5'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $this->assertEquals($compareData, unserialize($data[3]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[3]->analysisStatus); $compareData = array(); $compareData['column_0'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_1'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_2'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_3'][] = 'Is an existing record and will be updated.'; $compareData['column_4'][] = 'Is an existing record and will be updated.'; $compareData['column_5'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $this->assertEquals($compareData, unserialize($data[4]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[4]->analysisStatus); $compareData = array(); $compareData['column_0'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_1'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_2'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_3'][] = 'Is an existing record and will be updated.'; $compareData['column_4'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_5'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $this->assertEquals($compareData, unserialize($data[5]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[5]->analysisStatus); $compareData = array(); $compareData['column_0'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_1'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_2'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_3'][] = 'Is an existing record and will be updated.'; $compareData['column_4'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $compareData['column_5'][] = 'Is an existing record and will be updated.'; $this->assertEquals($compareData, unserialize($data[6]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[6]->analysisStatus); $compareData = array(); $compareData['column_0'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_1'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_2'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_3'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_4'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $compareData['column_5'][] = 'Is an existing record and will be updated.'; $this->assertEquals($compareData, unserialize($data[7]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[7]->analysisStatus); $compareData = array(); $compareData['column_0'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_1'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_2'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_3'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_4'][] = 'Was not found and this row will be skipped during import.'; $compareData['column_5'][] = 'Is an existing record and will be updated.'; $compareData['column_6'][] = 'Status specified is invalid and this row will be skipped during import.'; $this->assertEquals($compareData, unserialize($data[8]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[8]->analysisStatus); //Will result with no problems since it is all blank. $this->assertFalse(unserialize($data[9]->serializedAnalysisMessages)); $this->assertEquals(ImportDataAnalyzer::STATUS_CLEAN, $data[9]->analysisStatus); }
public function testProcessForActivityItems() { $account = AccountTestHelper::createAccountByNameForOwner('testAccount', Yii::app()->user->userModel); $task = TaskTestHelper::createTaskWithOwnerAndRelatedAccount('testTask', Yii::app()->user->userModel, $account); $meeting = MeetingTestHelper::createMeetingWithOwnerAndRelatedAccount('testMeetig', Yii::app()->user->userModel, $account); $contact = ContactTestHelper::createContactByNameForOwner('testContact', Yii::app()->user->userModel); $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('testOpportunity', Yii::app()->user->userModel); $task->activityItems->add($contact); $task->activityItems->add($opportunity); $meeting->activityItems->add($contact); $meeting->activityItems->add($opportunity); $this->assertTrue($task->save()); $this->assertTrue($meeting->save()); $emailTemplate = new EmailTemplate(); $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML; $emailTemplate->modelClassName = 'Task'; $emailTemplate->type = 1; $emailTemplate->name = 'some template'; $emailTemplate->subject = 'some subject [[NAME]]'; $emailTemplate->htmlContent = 'Account: [[ACCOUNT__NAME]] Contact: [[CONTACT__FIRST^NAME]] Opportunity: [[OPPORTUNITY__NAME]]'; $emailTemplate->textContent = 'Account: [[ACCOUNT__NAME]] Contact: [[CONTACT__FIRST^NAME]] Opportunity: [[OPPORTUNITY__NAME]]'; $this->assertTrue($emailTemplate->save()); $message = new EmailMessageForWorkflowForm('Task', Workflow::TYPE_ON_SAVE); $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER)); $message->emailTemplateId = $emailTemplate->id; $message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_CUSTOM; $message->sendFromAddress = '*****@*****.**'; $message->sendFromName = 'Jason'; $message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients)); $helper = new WorkflowEmailMessageProcessingHelper($message, $task, Yii::app()->user->userModel); $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount()); $this->assertEquals(0, Yii::app()->emailHelper->getSentCount()); $helper->process(); $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount()); $this->assertEquals(0, Yii::app()->emailHelper->getSentCount()); $emailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX); $this->assertEquals('some subject testTask', $emailMessages[0]->subject); $this->assertEquals('Account: testAccount Contact: testContact Opportunity: testOpportunity', $emailMessages[0]->content->textContent); $this->assertEquals('Account: testAccount Contact: testContact Opportunity: testOpportunity', $emailMessages[0]->content->htmlContent); $this->assertEquals('Jason', $emailMessages[0]->sender->fromName); $this->assertEquals('*****@*****.**', $emailMessages[0]->sender->fromAddress); $this->assertEquals(1, $emailMessages[0]->recipients->count()); $this->assertEquals('*****@*****.**', $emailMessages[0]->recipients[0]->toAddress); $taskId = $task->id; $task->forgetAll(); $task = Task::getById($taskId); $message = new EmailMessageForWorkflowForm('Task', Workflow::TYPE_ON_SAVE); $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER)); $message->emailTemplateId = $emailTemplate->id; $message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_CUSTOM; $message->sendFromAddress = '*****@*****.**'; $message->sendFromName = 'Jason'; $message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients)); $helper = new WorkflowEmailMessageProcessingHelper($message, $task, Yii::app()->user->userModel); $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount()); $this->assertEquals(0, Yii::app()->emailHelper->getSentCount()); $helper->process(); $this->assertEquals(2, Yii::app()->emailHelper->getQueuedCount()); $this->assertEquals(0, Yii::app()->emailHelper->getSentCount()); $emailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX); $this->assertEquals('some subject testTask', $emailMessages[1]->subject); $this->assertEquals('Account: testAccount Contact: testContact Opportunity: testOpportunity', $emailMessages[1]->content->textContent); $this->assertEquals('Account: testAccount Contact: testContact Opportunity: testOpportunity', $emailMessages[1]->content->htmlContent); $this->assertEquals('Jason', $emailMessages[1]->sender->fromName); $this->assertEquals('*****@*****.**', $emailMessages[1]->sender->fromAddress); $this->assertEquals(1, $emailMessages[1]->recipients->count()); $this->assertEquals('*****@*****.**', $emailMessages[1]->recipients[0]->toAddress); $emailMessages[0]->delete(); $emailMessages[1]->delete(); }
/** * @deletes selected leads. */ public function testRegularMassDeleteActionsForSelectedIds() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $confused = User::getByUsername('confused'); $nobody = User::getByUsername('nobody'); $this->assertEquals(Right::DENY, $confused->getEffectiveRight('ZurmoModule', ZurmoModule::RIGHT_BULK_DELETE)); $confused->setRight('ZurmoModule', ZurmoModule::RIGHT_BULK_DELETE); //Load MassDelete view for the 3 opportunities. $opportunities = Opportunity::getAll(); $this->assertEquals(9, count($opportunities)); $opportunity1 = OpportunityTestHelper::createOpportunityByNameForOwner('oppotunityDelete1', $confused); $opportunity2 = OpportunityTestHelper::createOpportunityByNameForOwner('oppotunityDelete2', $confused); $opportunity3 = OpportunityTestHelper::createOpportunityByNameForOwner('oppotunityDelete3', $nobody); $opportunity4 = OpportunityTestHelper::createOpportunityByNameForOwner('oppotunityDelete4', $confused); $opportunity5 = OpportunityTestHelper::createOpportunityByNameForOwner('oppotunityDelete5', $confused); $opportunity6 = OpportunityTestHelper::createOpportunityByNameForOwner('oppotunityDelete6', $nobody); $selectedIds = $opportunity1->id . ',' . $opportunity2->id . ',' . $opportunity3->id; // Not Coding Standard $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '')); // Not Coding Standard $this->resetPostArray(); $content = $this->runControllerWithNoExceptionsAndGetContent('opportunities/default/massDelete'); $this->assertFalse(strpos($content, '<strong>3</strong> Opportunities selected for removal') === false); $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize'); $this->assertEquals(5, $pageSize); //calculating leads after adding 6 new records $opportunities = Opportunity::getAll(); $this->assertEquals(15, count($opportunities)); //Deleting 6 opportunities for pagination scenario //Run Mass Delete using progress save for page1 $selectedIds = $opportunity1->id . ',' . $opportunity2->id . ',' . $opportunity3->id . ',' . $opportunity4->id . ',' . $opportunity5->id . ',' . $opportunity6->id; // Not Coding Standard $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '', 'Opportunity_page' => 1)); $this->setPostArray(array('selectedRecordCount' => 6)); $content = $this->runControllerWithExitExceptionAndGetContent('opportunities/default/massDelete'); $opportunities = Opportunity::getAll(); $this->assertEquals(10, count($opportunities)); //Run Mass Delete using progress save for page2 $selectedIds = $opportunity1->id . ',' . $opportunity2->id . ',' . $opportunity3->id . ',' . $opportunity4->id . ',' . $opportunity5->id . ',' . $opportunity6->id; // Not Coding Standard $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '', 'Opportunity_page' => 2)); $this->setPostArray(array('selectedRecordCount' => 6)); $content = $this->runControllerWithNoExceptionsAndGetContent('opportunities/default/massDeleteProgress'); $opportunities = Opportunity::getAll(); $this->assertEquals(9, count($opportunities)); }