/** * @test */ public function testIsDefault() { $branches = array(new Branch(8, 'DUMMY_NAME', "DUMMY_DESC"), new Branch(9, 'DUMMY_NAME', "DUMMY_DESC")); $this->systemSettings->expects($this->any())->method('getDefaultBranchId')->will($this->returnValue(self::DEFAULT_BRANCH_ID)); $result = $this->placeholder->isDefault($branches[0]); $this->assertTrue($result); $result = $this->placeholder->isDefault($branches[1]); $this->assertFalse($result); }
/** * @test */ public function thatHandlesAndDeletesMessages() { $messages = $this->getMessages(); $strategies = array($this->strategy); $this->settings->expects($this->any())->method('getDeleteProcessedMessages')->will($this->returnValue(true)); $this->provider->expects($this->once())->method('fetchMessagesToProcess')->will($this->returnValue($messages)); $this->strategyHolder->expects($this->once())->method('getStrategies')->will($this->returnValue($strategies)); $this->context->expects($this->exactly(count($strategies)))->method('setStrategy')->with($this->isInstanceOf('\\Diamante\\EmailProcessingBundle\\Model\\Processing\\Strategy')); $this->context->expects($this->exactly(count($messages) * count($strategies)))->method('execute')->with($this->isInstanceOf('Diamante\\EmailProcessingBundle\\Model\\Message')); $this->provider->expects($this->once())->method('deleteProcessedMessages'); $this->manager->handle($this->provider); }
public function testProcessWhenMessageWithoutReferenceWithDefaultBranch() { $message = new Message(self::DUMMY_UNIQUE_ID, self::DUMMY_MESSAGE_ID, self::DUMMY_SUBJECT, self::DUMMY_CONTENT, $this->getDummyFrom(), self::DUMMY_MESSAGE_TO); $assigneeId = 1; $diamanteUser = $this->getReporter(1); $this->userService->expects($this->once())->method('getUserByEmail')->with($this->equalTo(self::DUMMY_MESSAGE_FROM))->will($this->returnValue($diamanteUser)); $reporter = $this->getReporter($diamanteUser->getId()); preg_match('/@(.*)/', self::DUMMY_MESSAGE_FROM, $output); $customerDomain = $output[1]; $this->branchEmailConfigurationService->expects($this->once())->method('getConfigurationBySupportAddressAndCustomerDomain')->with($this->equalTo(self::DUMMY_MESSAGE_TO), $this->equalTo($customerDomain))->will($this->returnValue(null)); $this->emailProcessingSettings->expects($this->once())->method('getDefaultBranchId')->will($this->returnValue(self::DEFAULT_BRANCH_ID)); $this->messageReferenceService->expects($this->once())->method('createTicket')->with($this->equalTo($message->getMessageId()), self::DEFAULT_BRANCH_ID, $message->getSubject(), $message->getContent(), $reporter, $assigneeId); $this->branchEmailConfigurationService->expects($this->once())->method('getBranchDefaultAssignee')->with($this->equalTo($assigneeId))->will($this->returnValue(1)); $this->ticketStrategy->process($message); }