Exemplo n.º 1
0
 public function testSettersAndGetters()
 {
     $firstName = uniqid('firstName');
     $lastName = uniqid('lastName');
     $fullName = sprintf('%s %s', $firstName, $lastName);
     $email = uniqid('@');
     $comment = uniqid('comment');
     $organizationName = uniqid('organizationName');
     $preferredContactMethod = uniqid('preferredContactMethod');
     $feedback = uniqid('feedback');
     $phone = uniqid('123123');
     $createdAt = new \DateTime();
     $updatedAt = new \DateTime();
     $lead = $this->getMock('OroCRM\\Bundle\\SalesBundle\\Entity\\Lead');
     $opportunity = $this->getMock('OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity');
     $workflowStep = $this->getMock('Oro\\Bundle\\WorkflowBundle\\Entity\\WorkflowStep');
     $workflowItem = $this->getMock('Oro\\Bundle\\WorkflowBundle\\Entity\\WorkflowItem');
     $contactReason = $this->getMock('OroCRM\\Bundle\\ContactUsBundle\\Entity\\ContactReason', [], [uniqid('label')]);
     $request = new ContactRequest();
     $request->setComment($comment);
     $request->setFeedback($feedback);
     $request->setEmailAddress($email);
     $request->setFirstName($firstName);
     $request->setLastName($lastName);
     $request->setPhone($phone);
     $request->setOrganizationName($organizationName);
     $request->setPreferredContactMethod($preferredContactMethod);
     $request->setCreatedAt($createdAt);
     $request->setUpdatedAt($updatedAt);
     $this->assertNull($request->getWorkflowStep());
     $this->assertNull($request->getWorkflowStep());
     $this->assertNull($request->getContactReason());
     $this->assertNull($request->getLead());
     $this->assertNull($request->getOpportunity());
     $request->setLead($lead);
     $request->setOpportunity($opportunity);
     $request->setContactReason($contactReason);
     $request->setWorkflowItem($workflowItem);
     $request->setWorkflowStep($workflowStep);
     $this->assertNull($request->getId());
     $this->assertSame($contactReason, $request->getContactReason());
     $this->assertEquals($comment, $request->getComment());
     $this->assertEquals($feedback, $request->getFeedback());
     $this->assertEquals($organizationName, $request->getOrganizationName());
     $this->assertEquals($email, $request->getEmailAddress());
     $this->assertEquals($firstName, $request->getFirstName());
     $this->assertEquals($lastName, $request->getLastName());
     $this->assertEquals($fullName, $request->getFullName());
     $this->assertEquals($fullName, (string) $request);
     $this->assertEquals($phone, $request->getPhone());
     $this->assertEquals($preferredContactMethod, $request->getPreferredContactMethod());
     $this->assertEquals($createdAt, $request->getCreatedAt());
     $this->assertEquals($updatedAt, $request->getUpdatedAt());
     $this->assertSame($lead, $request->getLead());
     $this->assertSame($opportunity, $request->getOpportunity());
     $this->assertSame($workflowStep, $request->getWorkflowStep());
     $this->assertSame($workflowItem, $request->getWorkflowItem());
     // should not provoke fatal error, because it's not mandatory field
     $request->setContactReason(null);
 }