예제 #1
0
 public static function createLeadWithAccountByNameForOwner($firstName, $owner, $account)
 {
     ContactsModule::loadStartingData();
     $contact = new Contact();
     $contact->firstName = $firstName;
     $contact->lastName = $firstName . 'son';
     $contact->owner = $owner;
     $contact->account = $account;
     $contact->state = LeadsUtil::getStartingState();
     $saved = $contact->save();
     assert('$saved');
     return $contact;
 }
 public function testSuperUserCompleteMatchVariations()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/matchingList');
     $message1 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message2 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message3 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $contact = ContactTestHelper::createContactByNameForOwner('gail', $super);
     $startingContactState = ContactsUtil::getStartingState();
     $startingLeadState = LeadsUtil::getStartingState();
     //test validating selecting an existing contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'select-contact-form-' . $message1->id, 'AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'contact-inline-create-form-' . $message1->id, 'Contact' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new lead
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'lead-inline-create-form-' . $message1->id, 'Lead' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test selecting existing contact and saving
     $this->assertNull($contact->primaryEmail->emailAddress);
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals('*****@*****.**', $contact->primaryEmail->emailAddress);
     $this->assertTrue($message1->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message1->folder);
     //test creating new contact and saving
     $this->assertEquals(1, Contact::getCount());
     $this->setGetArray(array('id' => $message2->id));
     $this->setPostArray(array('Contact' => array($message2->id => array('firstName' => 'George', 'lastName' => 'Patton', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals(2, Contact::getCount());
     $contacts = Contact::getByName('George Patton');
     $contact = $contacts[0];
     $this->assertTrue($message2->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message2->folder);
     //test creating new lead and saving
     $this->assertEquals(2, Contact::getCount());
     $this->setGetArray(array('id' => $message3->id));
     $this->setPostArray(array('Lead' => array($message3->id => array('firstName' => 'Billy', 'lastName' => 'Kid', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals(3, Contact::getCount());
     $contacts = Contact::getByName('Billy Kid');
     $contact = $contacts[0];
     $this->assertTrue($message3->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message3->folder);
 }
 /**
  * @depends testSuperUserCreateAction
  */
 public function testSuperUserConvertAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $startingLeadState = LeadsUtil::getStartingState();
     $startingContactState = ContactsUtil::getStartingState();
     $leads = Contact::getByName('myNewLead myNewLeadson');
     $this->assertEquals(1, count($leads));
     $lead = $leads[0];
     $this->assertTrue($lead->state == $startingLeadState);
     //Test just going to the convert page.
     $this->setGetArray(array('id' => $lead->id));
     $this->resetPostArray();
     //Test trying to convert by skipping account creation
     $this->runControllerWithNoExceptionsAndGetContent('leads/default/convert');
     $this->setGetArray(array('id' => $lead->id));
     $this->setPostArray(array('AccountSkip' => 'Not Used'));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $leadId = $lead->id;
     $lead->forget();
     $contact = Contact::getById($leadId);
     $this->assertTrue($contact->state == $startingContactState);
     //Test trying to convert by creating a new account.
     $lead5 = LeadTestHelper::createLeadbyNameForOwner('superLead5', $super);
     $this->assertTrue($lead5->state == $startingLeadState);
     $this->setGetArray(array('id' => $lead5->id));
     $this->setPostArray(array('Account' => array('name' => 'someAccountName')));
     $this->assertEquals(0, count(Account::getAll()));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->assertEquals(1, count(Account::getAll()));
     $lead5Id = $lead5->id;
     $lead5->forget();
     $contact5 = Contact::getById($lead5Id);
     $this->assertTrue($contact5->state == $startingContactState);
     $this->assertEquals('someAccountName', $contact5->account->name);
     //Test trying to convert by selecting an existing account
     $account = AccountTestHelper::createAccountbyNameForOwner('someNewAccount', $super);
     $lead6 = LeadTestHelper::createLeadbyNameForOwner('superLead6', $super);
     $this->assertTrue($lead6->state == $startingLeadState);
     $this->setGetArray(array('id' => $lead6->id));
     $this->setPostArray(array('AccountSelectForm' => array('accountId' => $account->id, 'accountName' => 'someNewAccount')));
     $this->assertEquals(2, count(Account::getAll()));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->assertEquals(2, count(Account::getAll()));
     $lead6Id = $lead6->id;
     $lead6->forget();
     $contact6 = Contact::getById($lead6Id);
     $this->assertTrue($contact6->state == $startingContactState);
     $this->assertEquals($account, $contact6->account);
 }
예제 #4
0
 /**
  * @depends testApiServerUrl
  */
 public function testCreateLead()
 {
     $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');
     $industryValues = array('Automotive', 'Adult Entertainment', 'Financial Services', 'Mercenaries & Armaments');
     $industryFieldData = CustomFieldData::getByName('Industries');
     $industryFieldData->serializedData = serialize($industryValues);
     $this->assertTrue($industryFieldData->save());
     $sourceValues = array('Word of Mouth', 'Outbound', 'Trade Show');
     $sourceFieldData = CustomFieldData::getByName('LeadSources');
     $sourceFieldData->serializedData = serialize($sourceValues);
     $this->assertTrue($sourceFieldData->save());
     $titles = array('Mr.', 'Mrs.', 'Ms.', 'Dr.', 'Swami');
     $customFieldData = CustomFieldData::getByName('Titles');
     $customFieldData->serializedData = serialize($titles);
     $this->assertTrue($customFieldData->save());
     $this->assertEquals(6, count(ContactState::GetAll()));
     $contactStates = ContactState::GetAll();
     $primaryEmail['emailAddress'] = "*****@*****.**";
     $primaryEmail['optOut'] = 1;
     $secondaryEmail['emailAddress'] = "*****@*****.**";
     $secondaryEmail['optOut'] = 0;
     $secondaryEmail['isInvalid'] = 1;
     $primaryAddress['street1'] = '129 Noodle Boulevard';
     $primaryAddress['street2'] = 'Apartment 6000A';
     $primaryAddress['city'] = 'Noodleville';
     $primaryAddress['postalCode'] = '23453';
     $primaryAddress['country'] = 'The Good Old US of A';
     $secondaryAddress['street1'] = '25 de Agosto 2543';
     $secondaryAddress['street2'] = 'Local 3';
     $secondaryAddress['city'] = 'Ciudad de Los Fideos';
     $secondaryAddress['postalCode'] = '5123-4';
     $secondaryAddress['country'] = 'Latinoland';
     $account = new Account();
     $account->name = 'Some Account';
     $account->owner = $super;
     $this->assertTrue($account->save());
     $data['firstName'] = "Michael";
     $data['lastName'] = "Smith";
     $data['jobTitle'] = "President";
     $data['department'] = "Sales";
     $data['officePhone'] = "653-235-7824";
     $data['mobilePhone'] = "653-235-7821";
     $data['officeFax'] = "653-235-7834";
     $data['description'] = "Some desc.";
     $data['companyName'] = "Michael Co";
     $data['website'] = "http://sample.com";
     $data['industry']['value'] = $industryValues[2];
     $data['source']['value'] = $sourceValues[1];
     $data['title']['value'] = $titles[3];
     $data['state']['id'] = LeadsUtil::getStartingState()->id;
     $data['account']['id'] = $account->id;
     $data['primaryEmail'] = $primaryEmail;
     $data['secondaryEmail'] = $secondaryEmail;
     $data['primaryAddress'] = $primaryAddress;
     $data['secondaryAddress'] = $secondaryAddress;
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/leads/contact/api/create/', 'POST', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $data['owner'] = array('id' => $super->id, 'username' => 'super');
     $data['createdByUser'] = array('id' => $super->id, 'username' => 'super');
     $data['modifiedByUser'] = array('id' => $super->id, 'username' => 'super');
     // We need to unset some empty values from response.
     unset($response['data']['createdDateTime']);
     unset($response['data']['modifiedDateTime']);
     unset($response['data']['primaryEmail']['id']);
     unset($response['data']['primaryEmail']['isInvalid']);
     unset($response['data']['secondaryEmail']['id']);
     unset($response['data']['primaryAddress']['id']);
     unset($response['data']['primaryAddress']['state']);
     unset($response['data']['primaryAddress']['longitude']);
     unset($response['data']['primaryAddress']['latitude']);
     unset($response['data']['primaryAddress']['invalid']);
     unset($response['data']['secondaryAddress']['id']);
     unset($response['data']['secondaryAddress']['state']);
     unset($response['data']['secondaryAddress']['longitude']);
     unset($response['data']['secondaryAddress']['latitude']);
     unset($response['data']['secondaryAddress']['invalid']);
     unset($response['data']['industry']['id']);
     unset($response['data']['source']['id']);
     unset($response['data']['title']['id']);
     unset($response['data']['id']);
     unset($response['data']['googleWebTrackingId']);
     ksort($data);
     ksort($response['data']);
     $this->assertEquals($data, $response['data']);
 }
 public function testSuperUserCompleteMatchVariations()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/matchingList');
     $message1 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message1Id = $message1->id;
     $message2 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message2Id = $message2->id;
     $message3 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $contact = ContactTestHelper::createContactByNameForOwner('gail', $super);
     $startingContactState = ContactsUtil::getStartingState();
     $startingLeadState = LeadsUtil::getStartingState();
     //test validating selecting an existing contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'select-contact-form-' . $message1->id, 'AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'contact-inline-create-form-' . $message1->id, 'Contact' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new lead
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'lead-inline-create-form-' . $message1->id, 'Lead' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test selecting existing contact and saving
     $this->assertNull($contact->primaryEmail->emailAddress);
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $message1->forget();
     $message1 = EmailMessage::getById($message1Id);
     $this->assertNull($contact->primaryEmail->emailAddress);
     $this->assertCount(1, $message1->sender->personsOrAccounts);
     $this->assertTrue($message1->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message1->folder);
     //assert subject of the email going to edit.
     $this->setGetArray(array('id' => $contact->id));
     $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
     $this->assertEquals('A test unmatched archived received email', $message1->subject);
     //edit subject of email message.
     $this->setGetArray(array('id' => $message1->id));
     $createEmailMessageFormData = array('subject' => 'A test unmatched archived received email edited');
     $this->setPostArray(array('ajax' => 'edit-form', 'EmailMessage' => $createEmailMessageFormData));
     $this->runControllerWithRedirectExceptionAndGetUrl('emailMessages/default/edit');
     //assert subject is edited or not.
     $this->setGetArray(array('id' => $contact->id));
     $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
     $this->assertEquals('A test unmatched archived received email edited', $message1->subject);
     //delete email message.
     $this->setGetArray(array('id' => $message1->id));
     $this->runControllerWithRedirectExceptionAndGetUrl('emailMessages/default/delete', true);
     //assert subject not present.
     try {
         EmailMessage::getById($message1->id);
         $this->fail();
     } catch (NotFoundException $e) {
         //success
     }
     //Test the default permission was setted
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message1);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
     //test creating new contact and saving
     $this->assertEquals(1, Contact::getCount());
     $this->setGetArray(array('id' => $message2->id));
     $this->setPostArray(array('Contact' => array($message2->id => array('firstName' => 'George', 'lastName' => 'Patton', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $message2->forget();
     $message2 = EmailMessage::getById($message2Id);
     $this->assertEquals(2, Contact::getCount());
     $contacts = Contact::getByName('George Patton');
     $contact = $contacts[0];
     $this->assertCount(1, $message2->sender->personsOrAccounts);
     $this->assertTrue($message2->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message2->folder);
     //Test the default permission was setted
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message2);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
     //test creating new lead and saving
     $this->assertEquals(2, Contact::getCount());
     $this->setGetArray(array('id' => $message3->id));
     $this->setPostArray(array('Lead' => array($message3->id => array('firstName' => 'Billy', 'lastName' => 'Kid', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals(3, Contact::getCount());
     $contacts = Contact::getByName('Billy Kid');
     $contact = $contacts[0];
     $this->assertCount(1, $message3->sender->personsOrAccounts);
     $this->assertTrue($message3->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message3->folder);
     //Test the default permission was setted
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message3);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
 }
 /**
  * @depends testSuperUserCreateFromRelationAction
  */
 public function testSuperUserCopyAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $contacts = Contact::getByName('myNewContact myNewContactson');
     $this->assertCount(1, $contacts);
     $postArray = array('Contact' => array('firstName' => 'myNewContact', 'lastName' => 'myNewContactson', 'jobTitle' => 'job title', 'account' => array('name' => 'Linked account'), 'department' => 'Some department', 'officePhone' => '456765421', 'mobilePhone' => '958462315', 'officeFax' => '123456789', 'primaryEmail' => array('emailAddress' => '*****@*****.**'), 'secondaryEmail' => array('emailAddress' => '*****@*****.**'), 'primaryAddress' => array('street1' => 'Street1', 'street2' => 'Street2', 'city' => 'City', 'state' => 'State', 'postalCode' => '12345', 'country' => 'Country'), 'secondaryAddress' => array('street1' => 'Street1', 'street2' => 'Street2', 'city' => 'City', 'state' => 'State', 'postalCode' => '12345', 'country' => 'Country'), 'description' => 'some description'));
     $this->updateModelValuesFromPostArray($contacts[0], $postArray);
     $this->assertModelHasValuesFromPostArray($contacts[0], $postArray);
     $this->assertTrue($contacts[0]->save());
     $this->assertTrue($this->checkCopyActionResponseAttributeValuesFromPostArray($contacts[0], $postArray));
     $postArray['Contact']['firstName'] = 'myClonedContact';
     $postArray['Contact']['lastName'] = 'myClonedContactson';
     $postArray['Contact']['state'] = array('id' => LeadsUtil::getStartingState()->id);
     $this->setGetArray(array('id' => $contacts[0]->id));
     $this->setPostArray($postArray);
     $this->runControllerWithRedirectExceptionAndGetUrl('contacts/default/copy');
     $contacts = Contact::getByName('myClonedContact myClonedContactson');
     $this->assertCount(1, $contacts);
     $this->assertTrue($contacts[0]->owner->isSame($super));
     unset($postArray['Contact']['state']);
     $this->assertModelHasValuesFromPostArray($contacts[0], $postArray);
     $contacts = Contact::getAll();
     $this->assertCount(15, $contacts);
     $contacts = Contact::getByName('myClonedContact myClonedContactson');
     $this->assertCount(1, $contacts);
     $this->assertTrue($contacts[0]->delete());
 }
예제 #7
0
 public function testLeadsStateMetadataAdapterWithNoStates()
 {
     $metadata = ContactsModule::getMetadata();
     $metadata['global']['startingStateId'] = LeadsUtil::getStartingState()->id;
     ContactsModule::setMetadata($metadata);
     $adapter = new LeadsStateMetadataAdapter(array('clauses' => array(), 'structure' => ''));
     $adaptedMetadata = $adapter->getAdaptedDataProviderMetadata();
     $compareMetadata = array('clauses' => array(1 => array('attributeName' => 'state', 'operatorType' => 'equals', 'value' => '-1')), 'structure' => '(1)');
     $this->assertEquals($compareMetadata, $adaptedMetadata);
 }
 /**
  * @depends testSuperUserCreateAction
  */
 public function testSuperUserConvertAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $startingLeadState = LeadsUtil::getStartingState();
     $startingContactState = ContactsUtil::getStartingState();
     $leads = Contact::getByName('myNewLead myNewLeadson');
     $this->assertEquals(1, count($leads));
     $lead = $leads[0];
     $this->assertTrue($lead->state == $startingLeadState);
     //Test just going to the convert page.
     $this->setGetArray(array('id' => $lead->id));
     $this->resetPostArray();
     //Test trying to convert by skipping account creation and by skipping opportunity creation
     $this->runControllerWithNoExceptionsAndGetContent('leads/default/convert');
     $this->setGetArray(array('id' => $lead->id));
     $this->setPostArray(array('AccountSkip' => 'Not Used'));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->setGetArray(array('id' => $lead->id));
     $this->setPostArray(array('OpportunitySkip' => 'Not Used'));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
     $leadId = $lead->id;
     $lead->forget();
     $contact = Contact::getById($leadId);
     $this->assertTrue($contact->state == $startingContactState);
     //Test trying to convert by creating a new account and by skipping opportunity creation.
     $lead5 = LeadTestHelper::createLeadbyNameForOwner('superLead5', $super);
     $this->assertTrue($lead5->state == $startingLeadState);
     $this->setGetArray(array('id' => $lead5->id));
     $this->setPostArray(array('Account' => array('name' => 'someAccountName')));
     $this->assertEquals(0, Account::getCount());
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->setGetArray(array('id' => $lead5->id));
     $this->setPostArray(array('OpportunitySkip' => 'Not Used'));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
     $this->assertEquals(1, Account::getCount());
     $lead5Id = $lead5->id;
     $lead5->forget();
     $contact5 = Contact::getById($lead5Id);
     $this->assertTrue($contact5->state == $startingContactState);
     $this->assertEquals('someAccountName', $contact5->account->name);
     //Test trying to convert by selecting an existing account and by skipping opportunity creation.
     $account = AccountTestHelper::createAccountbyNameForOwner('someNewAccount', $super);
     $lead6 = LeadTestHelper::createLeadbyNameForOwner('superLead6', $super);
     $this->assertTrue($lead6->state == $startingLeadState);
     $this->setGetArray(array('id' => $lead6->id));
     $this->setPostArray(array('AccountSelectForm' => array('accountId' => $account->id, 'accountName' => 'someNewAccount')));
     $this->assertEquals(2, Account::getCount());
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->setGetArray(array('id' => $lead6->id));
     $this->setPostArray(array('OpportunitySkip' => 'Not Used'));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
     $this->assertEquals(2, Account::getCount());
     $lead6Id = $lead6->id;
     $lead6->forget();
     $contact6 = Contact::getById($lead6Id);
     $this->assertTrue($contact6->state == $startingContactState);
     $this->assertEquals($account, $contact6->account);
     //Test trying to convert by skipping account creation and by creating new opportunity
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $leadOpp = LeadTestHelper::createLeadbyNameForOwner('superLeadOpp', $super);
     $this->setGetArray(array('id' => $leadOpp->id));
     $this->setPostArray(array('AccountSkip' => 'Not Used'));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->setGetArray(array('id' => $leadOpp->id));
     $this->setPostArray(array('Opportunity' => array('name' => 'someOpportunityName', 'amount' => array('currency' => array('id' => '1'), 'value' => '100'), 'closeDate' => '6/19/2014', 'stage' => array('value' => 'Negotiating'), 'probability' => '50')));
     $this->assertEquals(0, Opportunity::getCount());
     $this->assertEquals(2, Account::getCount());
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
     $leadId = $leadOpp->id;
     $leadOpp->forget();
     $contact = Contact::getById($leadId);
     $this->assertTrue($contact->state == $startingContactState);
     $this->assertEquals(1, Opportunity::getCount());
     $this->assertEquals(2, Account::getCount());
 }