예제 #1
0
 /**
  * @depends testCreateStateValues
  */
 public function testGetSetConvertToAccountSetting()
 {
     $this->assertEquals(2, LeadsModule::getConvertToAccountSetting());
     $this->assertEquals(2, LeadsModule::CONVERT_ACCOUNT_NOT_REQUIRED);
     $metadata = LeadsModule::getMetadata();
     $metadata['global']['convertToAccountSetting'] = LeadsModule::CONVERT_ACCOUNT_REQUIRED;
     LeadsModule::setMetadata($metadata);
     $this->assertEquals(3, LeadsModule::getConvertToAccountSetting());
 }
 /**
  * @depends testUserCanAccessAccountsButCannotCreateAccountShowConvertAction
  */
 public function testLeadConversionMisconfigurationScenarios()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $bubby = UserTestHelper::createBasicUser('bubby');
     $lead = LeadTestHelper::createLeadbyNameForOwner('BelinaLead1', $bubby);
     $bubby->setRight('LeadsModule', LeadsModule::RIGHT_CONVERT_LEADS, Right::ALLOW);
     $bubby->setRight('LeadsModule', LeadsModule::RIGHT_ACCESS_LEADS, Right::ALLOW);
     $this->assertTrue($bubby->save());
     //Scenario #1 - User does not have access to contacts
     $this->assertEquals(Right::DENY, $bubby->getEffectiveRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS));
     $bubby = $this->logoutCurrentUserLoginNewUserAndGetByUsername('bubby');
     //View will not show up properly.
     $this->setGetArray(array('id' => $lead->id));
     $content = $this->runControllerWithExitExceptionAndGetContent('leads/default/convert');
     $this->assertContains('Conversion requires access to the contacts module which you do not have. Please contact your administrator.', $content);
     //Scenario #2 - User cannot access accounts and an account is required for conversion
     $bubby->setRight('ContactsModule', ContactsModule::RIGHT_CREATE_CONTACTS, Right::ALLOW);
     $bubby->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS, Right::ALLOW);
     $this->assertTrue($bubby->save());
     $metadata = LeadsModule::getMetadata();
     $metadata['global']['convertToAccountSetting'] = LeadsModule::CONVERT_ACCOUNT_REQUIRED;
     LeadsModule::setMetadata($metadata);
     //At this point because the account is required, the view will not come up properly.
     $this->setGetArray(array('id' => $lead->id));
     $content = $this->runControllerWithExitExceptionAndGetContent('leads/default/convert');
     $this->assertContains('Conversion is set to require an account.  Currently you do not have access to the accounts module.', $content);
     //Scenario #3 - User cannot access opportunities and an opportunity is required for conversion
     $metadata = LeadsModule::getMetadata();
     $metadata['global']['convertToAccountSetting'] = LeadsModule::CONVERT_ACCOUNT_NOT_REQUIRED;
     $metadata['global']['convertToOpportunitySetting'] = LeadsModule::CONVERT_OPPORTUNITY_REQUIRED;
     LeadsModule::setMetadata($metadata);
     //At this point because the opportunity is required, the view will not come up properly.
     $this->setGetArray(array('id' => $lead->id));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->setGetArray(array('id' => $lead->id));
     $content = $this->runControllerWithExitExceptionAndGetContent('leads/default/convertFinal');
     $this->assertContains('Conversion is set to require an opportunity.  Currently you do not have access to the opportunities module.', $content);
 }