Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Tests\Download;
- use App\Download\DownloadableInterface;
- use App\Download\DownloadHelper;
- use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
- use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
- class DownloadHelperTest extends KernelTestCase
- {
- /**
- * Test uploadPath function
- */
- public function testGetUploadPath(){
- $uploadDirData = 'upload/files/';
- $fileData = 'AZERT1234';
- $parameterBagInterface = $this->createMock(ParameterBagInterface::class);
- $parameterBagInterface->expects($this->once())
- ->method('get')
- ->willReturn($uploadDirData);
- $downloadHelper = new DownloadHelper($parameterBagInterface);
- $fileTest = new TestFile();
- $fileTest->setFile($fileData);
- $expected = $uploadDirData . $fileData;
- $result = $downloadHelper->getUploadPath($fileTest);
- $this->assertEquals($expected, $result, 'The directory to download one resource fail');
- }
- }
- class TestFile implements DownloadableInterface
- {
- private $file;
- /**
- * @return null|string
- */
- public function getFile(): ?string
- {
- return $this->file;
- }
- /**
- * @param string $file
- * @return $this
- */
- public function setFile(string $file){
- $this->file = $file ;
- return $this;
- }
- }
Add Comment
Please, Sign In to add comment