/**
  * @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);
 }
 /**
  * @test
  * @expectedException \RuntimeException
  */
 public function thatFileUploadThrowExceptionWhenDirectoryDoesNotExist()
 {
     $this->dirMock = new FileInfoStub(self::NON_EXISTENT_DIR, false, false);
     $this->handler = new BranchLogoHandler($this->dirMock, $this->fileSysMock);
     $this->fileMock = new UploadedFileStub($this->fixturesDir . '/' . self::PNG_FIXTURE_NAME, self::PNG_FIXTURE_NAME, 'image/png');
     $this->assertEquals('image/png', $this->fileMock->getMimeType());
     $this->assertEquals('png', strtolower($this->fileMock->guessExtension()));
     $this->assertEquals(false, $this->dirMock->isDir());
     $this->assertEquals(false, $this->dirMock->isWritable());
     $this->handler->upload($this->fileMock, self::PNG_FIXTURE_NAME);
 }