/**
  * @test
  */
 public function filelinkCreatesCorrectUrlForFileWithUrlEncodedSpecialChars()
 {
     $fileNameAndPath = PATH_site . 'typo3temp/var/tests/phpunitJumpUrlTestFile with spaces & amps.txt';
     file_put_contents($fileNameAndPath, 'Some test data');
     $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site));
     $fileName = substr($fileNameAndPath, strlen(PATH_site . 'typo3temp/var/tests/'));
     $expectedLink = str_replace('%2F', '/', rawurlencode($relativeFileNameAndPath));
     $result = $this->subject->filelink($fileName, array('path' => 'typo3temp/var/tests/'));
     $this->assertEquals('<a href="' . $expectedLink . '">' . $fileName . '</a>', $result);
     \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($fileNameAndPath);
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function filelinkDisablesGlobalJumpUrlWithDeprecatedOptionIfConfigured()
 {
     $testData = $this->initializeJumpUrlTestEnvironment($this->never());
     $fileName = 'phpunitJumpUrlTestFile.txt';
     $fileNameAndPath = 'typo3temp/' . $fileName;
     file_put_contents(PATH_site . $fileNameAndPath, 'Some test data');
     $expectedLink = $testData['absRefPrefix'] . $fileNameAndPath;
     $expectedLink = '<a href="' . $expectedLink . '">' . $fileName . '</a>';
     // Test with deprecated configuration
     $result = $this->subject->filelink($fileName, array('path' => 'typo3temp/', 'jumpurl' => 0));
     $this->assertEquals($expectedLink, $result);
     GeneralUtility::unlink_tempfile($fileNameAndPath);
 }