Guest User

Untitled

a guest
Jun 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Tests\Download;
  4.  
  5. use App\Download\DownloadableInterface;
  6. use App\Download\DownloadHelper;
  7. use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
  8. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  9.  
  10. class DownloadHelperTest extends KernelTestCase
  11. {
  12.  
  13. /**
  14. * Test uploadPath function
  15. */
  16. public function testGetUploadPath(){
  17.  
  18. $uploadDirData = 'upload/files/';
  19. $fileData = 'AZERT1234';
  20.  
  21. $parameterBagInterface = $this->createMock(ParameterBagInterface::class);
  22. $parameterBagInterface->expects($this->once())
  23. ->method('get')
  24. ->willReturn($uploadDirData);
  25.  
  26. $downloadHelper = new DownloadHelper($parameterBagInterface);
  27.  
  28. $fileTest = new TestFile();
  29. $fileTest->setFile($fileData);
  30.  
  31. $expected = $uploadDirData . $fileData;
  32.  
  33. $result = $downloadHelper->getUploadPath($fileTest);
  34. $this->assertEquals($expected, $result, 'The directory to download one resource fail');
  35. }
  36. }
  37.  
  38. class TestFile implements DownloadableInterface
  39. {
  40.  
  41. private $file;
  42.  
  43. /**
  44. * @return null|string
  45. */
  46. public function getFile(): ?string
  47. {
  48. return $this->file;
  49. }
  50.  
  51. /**
  52. * @param string $file
  53. * @return $this
  54. */
  55. public function setFile(string $file){
  56. $this->file = $file ;
  57. return $this;
  58. }
  59. }
Add Comment
Please, Sign In to add comment