/** * Gets a list of all phone numbers available for the given B2bCustomer object * * @param B2bCustomer $object * * @return array of [phone number, phone owner] */ public function getPhoneNumbers($object) { $contact = $object->getContact(); if (!$contact) { return []; } return $this->rootProvider->getPhoneNumbers($contact); }
public function testGetPhoneNumbers() { $entity = new B2bCustomer(); $contact = $this->getMockBuilder('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact')->disableOriginalConstructor()->getMock(); $entity->setContact($contact); $this->rootProvider->expects($this->once())->method('getPhoneNumbers')->with($this->identicalTo($contact))->will($this->returnValue([['123-123', $contact], ['456-456', $contact]])); $this->assertEquals([['123-123', $contact], ['456-456', $contact]], $this->provider->getPhoneNumbers($entity)); }
/** * @depends testChangeStatusAffectsLifetime * * @param Opportunity $opportunity * * @return Opportunity */ public function testCustomerChangeShouldUpdateBothCustomersIfValuable(Opportunity $opportunity) { $em = $this->getEntityManager(); $b2bCustomer = $opportunity->getCustomer(); $this->assertEquals(100, $b2bCustomer->getLifetime()); $newCustomer = new B2bCustomer(); $newCustomer->setName(uniqid('name')); $newCustomer->setDataChannel($opportunity->getDataChannel()); $em->persist($newCustomer); $em->flush(); $this->assertEquals(0, $newCustomer->getLifetime()); $opportunity->setCustomer($newCustomer); $em->persist($opportunity); $em->flush(); $em->refresh($b2bCustomer); $em->refresh($newCustomer); $this->assertEquals(0, $b2bCustomer->getLifetime()); $this->assertEquals(100, $newCustomer->getLifetime()); return $opportunity; }
public function testCreate() { $crawler = $this->client->request('GET', $this->getUrl('orocrm_sales_opportunity_create')); /** @var Form $form */ $form = $crawler->selectButton('Save and Close')->form(); $name = 'name' . $this->generateRandomString(); $form['orocrm_sales_opportunity_form[name]'] = $name; $form['orocrm_sales_opportunity_form[customer]'] = self::$customer->getId(); $form['orocrm_sales_opportunity_form[probability]'] = 50; $form['orocrm_sales_opportunity_form[budgetAmount]'] = 10000; $form['orocrm_sales_opportunity_form[customerNeed]'] = 10001; $form['orocrm_sales_opportunity_form[closeReason]'] = 'cancelled'; $form['orocrm_sales_opportunity_form[owner]'] = 1; $form['orocrm_sales_opportunity_form[dataChannel]'] = $this->getReference('default_channel')->getId(); $this->client->followRedirects(true); $crawler = $this->client->submit($form); $result = $this->client->getResponse(); $this->assertHtmlResponseStatusCodeEquals($result, 200); $this->assertContains("Opportunity saved", $crawler->html()); return $name; }
public function testGetEmail() { $account = $this->getMockBuilder('OroCRM\\Bundle\\AccountBundle\\Entity\\Account')->disableOriginalConstructor()->getMock(); $contact = $this->getMockBuilder('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact')->disableOriginalConstructor()->getMock(); $this->assertNull($this->entity->getEmail()); $this->entity->setAccount($account); $account->expects($this->once())->method('getEmail')->will($this->returnValue('*****@*****.**')); $this->assertEquals('*****@*****.**', $this->entity->getEmail()); $this->entity->setContact($contact); $contact->expects($this->once())->method('getEmail')->will($this->returnValue('*****@*****.**')); $this->assertEquals('*****@*****.**', $this->entity->getEmail()); }
public function testProcessWithoutLeadViewPermission() { $this->request->setMethod('POST'); $this->form->expects($this->once())->method('setData')->with($this->entity); $this->form->expects($this->once())->method('submit')->with($this->request); $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true)); $this->form->expects($this->any())->method('has')->will($this->returnValueMap([['leads', false], ['opportunities', false]])); $this->form->expects($this->never())->method('get'); $this->assertTrue($this->handler->process($this->entity)); $actualLeads = $this->entity->getLeads()->toArray(); $actualOpportunities = $this->entity->getOpportunities()->toArray(); $this->assertCount(0, $actualLeads); $this->assertEquals([], $actualLeads); $this->assertCount(0, $actualOpportunities); $this->assertEquals([], $actualOpportunities); }
/** * @param Organization $organization * @param array $data * @param Channel $channel * * @return B2bCustomer */ protected function createCustomer(Organization $organization, $data, Channel $channel = null) { $address = new Address(); $customer = new B2bCustomer(); $customer->setName($data['Company']); $customer->setOwner($this->getRandomUserReference()); $customer->setAccount($this->getAccount()); $customer->setOrganization($organization); $address->setCity($data['City']); $address->setStreet($data['StreetAddress']); $address->setPostalCode($data['ZipCode']); $address->setFirstName($data['GivenName']); $address->setLastName($data['Surname']); $address->setCountry($this->getCountryReference($data['Country'])); $address->setRegion($this->getRegionReference($data['Country'], $data['State'])); $customer->setShippingAddress($address); $customer->setBillingAddress(clone $address); if ($channel) { $customer->setDataChannel($channel); } return $customer; }
protected function createB2bCustomer() { $customer = new B2bCustomer(); $customer->setAccount($this->getReference('default_account')); $customer->setName(self::CUSTOMER_NAME); $customer->setDataChannel($this->getReference('default_channel')); $customer->setOrganization($this->organization); $this->em->persist($customer); $this->em->flush(); $this->setReference('default_b2bcustomer', $customer); return $this; }
/** * @param string $key * @param B2bCustomer $entity */ public function fillEntityData($key, $entity) { $addressRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\AddressBundle\\Entity\\Address'); $userRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\UserBundle\\Entity\\User'); $contactRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact'); $leadRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\SalesBundle\\Entity\\Lead'); $accountRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\AccountBundle\\Entity\\Account'); $channelRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel'); switch ($key) { case 'Jerry Coleman': $entity->setName('Jerry Coleman'); $entity->addLead($leadRepo->getEntity('Jerry Coleman')); $entity->setContact($contactRepo->getEntity('Jerry Coleman')); $entity->setAccount($accountRepo->getEntity('Coleman')); $entity->setOwner($userRepo->getEntity('John Doo')); $entity->setBillingAddress($addressRepo->getEntity('Jerry Coleman')); $entity->setShippingAddress($addressRepo->getEntity('Jerry Coleman')); $entity->setDataChannel($channelRepo->getEntity('B2b channel|b2b')); $entity->setCreatedAt(new \DateTime()); $entity->setUpdatedAt(new \DateTime()); return; } parent::fillEntityData($key, $entity); }
/** * Remove opportunities from B2bCustomer * * @param B2bCustomer $b2bCustomer * @param Opportunity[] $opportunities */ protected function removeOpportunities(B2bCustomer $b2bCustomer, array $opportunities) { foreach ($opportunities as $opportunity) { $b2bCustomer->removeOpportunity($opportunity); } }
public function testToSting() { $this->entity->setName(self::TEST_NAME); $this->assertSame(self::TEST_NAME, (string) $this->entity); }
/** * Calculates new lifetime value for customer * * @param B2bCustomer $b2bCustomer * * @return bool Returns true if value was changed, false otherwise * * @deprecated Use {@see calculateLifetimeValue} instead */ public function calculateLifetime(B2bCustomer $b2bCustomer) { $currentLifetime = $b2bCustomer->getLifetime(); $b2bCustomer->setLifetime($this->calculateLifetimeValue($b2bCustomer)); return $b2bCustomer->getLifetime() != $currentLifetime; }