Exemplo n.º 1
0
 public function testTicketKeyInitialization()
 {
     $ticketSequenceNumberValue = 12;
     $branch = new Branch('DB', 'DUMMY BRANCH', 'DUMYY_DESC');
     $reporter = $this->createReporter();
     $assignee = $this->createAssignee();
     $ticket = new Ticket(new UniqueId('unique_id'), new TicketSequenceNumber($ticketSequenceNumberValue), self::TICKET_SUBJECT, self::TICKET_DESCRIPTION, $branch, $reporter, $assignee, new Source(Source::PHONE), new Priority(Priority::PRIORITY_LOW), new Status(Status::OPEN));
     $this->assertEquals($branch->getKey() . '-' . $ticketSequenceNumberValue, (string) $ticket->getKey());
 }
 /**
  * @ORM\PrePersist
  * @param Branch $branch
  * @param LifecycleEventArgs $event
  */
 public function prePersistHandler(Branch $branch, LifecycleEventArgs $event)
 {
     $em = $event->getEntityManager();
     $query = $em->createQuery("SELECT b FROM DiamanteDeskBundle:Branch b WHERE b.key = :key")->setParameter('key', $branch->getKey());
     $result = $query->getResult();
     if (count($result) > 0) {
         throw new DuplicateBranchKeyException('Branch key already exists. Please, provide another one.');
     }
 }
 public function testPrePersistHandlerWhenKeyDoesNotExistYet()
 {
     $branch = new Branch('DUMM', 'Dummy', 'Desc');
     $event = new LifecycleEventArgs($branch, $this->objectManager);
     $dqlQueryStr = "SELECT b FROM DiamanteDeskBundle:Branch b WHERE b.key = :key";
     $query = $this->getMockBuilder('\\Doctrine\\ORM\\AbstractQuery')->disableOriginalConstructor()->setMethods(array('setParameter', 'getResult'))->getMockForAbstractClass();
     $this->objectManager->expects($this->once())->method('createQuery')->with($dqlQueryStr)->will($this->returnValue($query));
     $query->expects($this->once())->method('setParameter')->with('key', $branch->getKey())->will($this->returnValue($query));
     $query->expects($this->once())->method('getResult')->will($this->returnValue(array()));
     $listener = new BranchListener();
     $listener->prePersistHandler($branch, $event);
 }
 /**
  * @test
  */
 public function testBranchDefaultAssigneeRetrieved()
 {
     $this->branchRepository->expects($this->once())->method('get')->with($this->equalTo(1))->will($this->returnValue($this->branch));
     $this->branch->expects($this->once())->method('getDefaultAssigneeId')->will($this->returnValue(1));
     $assignee = $this->branchEmailConfigurationServiceImpl->getBranchDefaultAssignee(1);
     $this->assertEquals(1, $assignee);
 }
 public function testUpdateProperties()
 {
     $this->branchRepository->expects($this->once())->method('get')->will($this->returnValue($this->branch));
     $name = 'DUMMY_NAME_UPDT';
     $description = 'DUMMY_DESC_UPDT';
     $this->branch->expects($this->at(0))->method('updateProperty')->with($this->equalTo('name'), $this->equalTo($name));
     $this->branch->expects($this->at(1))->method('updateProperty')->with($this->equalTo('description'), $this->equalTo($description));
     $this->branchRepository->expects($this->once())->method('store')->with($this->equalTo($this->branch));
     $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('EDIT'), $this->equalTo('Entity:DiamanteDeskBundle:Branch'))->will($this->returnValue(true));
     $command = new UpdatePropertiesCommand();
     $command->id = 1;
     $command->properties = ['name' => $name, 'description' => $description];
     $this->branchServiceImpl->updateProperties($command);
 }
 /**
  * @param Command\BranchCommand $command
  * @param Branch $branch
  */
 protected function handleTagging(Command\BranchCommand $command, Branch $branch)
 {
     $tags = $command->getTags();
     $tags['owner'] = $tags['all'];
     $branch->setTags($tags);
 }
 /**
  * @test
  *
  * @expectedException \DomainException
  * @expectedExceptionMessage Branch does not have "invalid_property" property.
  */
 public function thatDoesNotUpdateInvalidProperty()
 {
     $branch = new Branch('DUMM', 'DUMMY_NAME', 'DUMMY_DESC');
     $branch->updateProperty('invalid_property', 'value');
 }
 public static function create(Branch $branch, Ticket $ticket)
 {
     return new TicketKey($branch->getKey(), $ticket->getSequenceNumber()->getValue());
 }
Exemplo n.º 9
0
 /**
  * @return string
  */
 public function getBranchName()
 {
     return $this->branch->getName();
 }
 public static function fromBranch(Branch $branch)
 {
     $command = new self();
     $command->id = $branch->getId();
     $command->name = $branch->getName();
     $command->description = $branch->getDescription();
     $command->defaultAssignee = $branch->getDefaultAssignee();
     $command->tags = $branch->getTags();
     $command->logoFile = null;
     $command->logo = $branch->getLogo();
     return $command;
 }