public function testAfterMergeEntity() { $this->entityData->expects($this->any())->method('getMasterEntity')->will($this->returnValue($this->createTaggableEntity('foo'))); $event = new EntityDataEvent($this->entityData); $this->manager->expects($this->once())->method('saveTagging'); $this->helper->expects($this->once())->method('isTaggable')->willReturn(true); $this->listener->afterMergeEntity($event); }
/** * @test */ public function updateBranchWithAllValues() { $this->fileMock = new UploadedFileStub(self::DUMMY_LOGO_PATH, self::DUMMY_LOGO_NAME); $uploadedFile = $this->fileMock->move(self::DUMMY_LOGO_PATH, self::DUMMY_LOGO_NAME); $this->branchRepository->expects($this->once())->method('get')->will($this->returnValue($this->branch)); $this->branch->expects($this->exactly(2))->method('getLogo')->will($this->returnValue($this->logo)); $this->branchLogoHandler->expects($this->once())->method('remove')->with($this->equalTo($this->logo)); $this->branchLogoHandler->expects($this->once())->method('upload')->with($this->equalTo($this->fileMock))->will($this->returnValue($uploadedFile)); $name = 'DUMMY_NAME_UPDT'; $description = 'DUMMY_DESC_UPDT'; $assigneeId = 1; $assignee = new User($assigneeId, User::TYPE_ORO); $defaultAssignee = new OroUser(); $tags = array('autocomplete' => array(), 'all' => array(), 'owner' => array()); $this->branch->expects($this->once())->method('update')->with($this->equalTo($name), $this->equalTo($description), $this->equalTo($defaultAssignee), $this->equalTo(new Logo($uploadedFile->getFilename(), $uploadedFile->getFilename()))); $this->branch->expects($this->once())->method('setTags')->with($this->equalTo($tags)); $this->registry->expects($this->exactly(2))->method('getManager')->will($this->returnValue($this->entityManager)); $this->entityManager->expects($this->once())->method('persist')->with($this->branch); $this->entityManager->expects($this->once())->method('flush'); $this->tagManager->expects($this->once())->method('saveTagging')->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)); $this->registry->expects($this->once())->method('getRepository')->with($this->equalTo('OroUserBundle:User'))->will($this->returnValue($this->userRepo)); $this->userRepo->expects($this->once())->method('find')->with($this->equalTo($assigneeId))->will($this->returnValue($defaultAssignee)); $command = new BranchCommand(); $command->name = $name; $command->description = $description; $command->defaultAssignee = $assigneeId; $command->logoFile = $this->fileMock; $command->tags = $tags; $this->branchServiceImpl->updateBranch($command); }
public function testRenderTicket() { $tags = array(array('id' => 1, 'name' => 'Ticket Tag')); $renderTagResult = '<span class="tag-inline">Ticket Tag</span>'; $this->registry->expects($this->once())->method('getRepository')->will($this->returnValue($this->sharedRepository)); $this->tagManager->expects($this->once())->method('loadTagging')->will($this->returnValue($this->tagManager)); $this->twig->expects($this->once())->method('render')->will($this->returnValue($renderTagResult)); $this->sharedRepository->expects($this->once())->method('get')->will($this->returnValue($this->ticket)); $this->ticket->expects($this->once())->method('getTags')->will($this->returnValue($this->commonCollection)); $this->commonCollection->expects($this->once())->method('getValues')->will($this->returnValue($tags)); $ticketResult = $this->renderTagExtensionExtension->renderTag($this->twig, 1, 'ticket'); $this->assertEquals($renderTagResult, $ticketResult); }
public function testGetList() { $entity = $this->getMock('Oro\\Bundle\\TagBundle\\Entity\\Taggable'); $this->manager->expects($this->once())->method('getPreparedArray')->with($entity); $this->extension->getList($entity); }