/**
  * @param Branch $branch
  * @return Logo
  */
 protected function removeBranchLogo(Branch $branch)
 {
     if (null !== $branch->getLogo()) {
         $this->branchLogoHandler->remove($branch->getLogo());
     }
     return new Logo();
 }
 /**
  * @test
  */
 public function testDeleteBranchWithoutLogo()
 {
     $branch = new Branch('DUMM', 'DUMMY_NAME', 'DUMMY_DESC');
     $this->branchRepository->expects($this->once())->method('get')->with($this->equalTo(self::DUMMY_BRANCH_ID))->will($this->returnValue($branch));
     $this->branchLogoHandler->expects($this->never())->method('remove');
     $this->branchRepository->expects($this->once())->method('remove')->with($this->equalTo($branch));
     $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('DELETE'), $this->equalTo('Entity:DiamanteDeskBundle:Branch'))->will($this->returnValue(true));
     $this->branchServiceImpl->deleteBranch(self::DUMMY_BRANCH_ID);
 }
 /**
  * @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);
 }
 /**
  * @param UploadedFile $file
  * @return \Symfony\Component\HttpFoundation\File\File
  */
 private function handleLogoUpload(UploadedFile $file)
 {
     return $this->branchLogoHandler->upload($file);
 }