TYPO3 CMS  TYPO3_6-2
DataSubmissionControllerTest.php
Go to the documentation of this file.
1 <?php
3 
23 
25  // tests concerning __destruct
27 
31  public function invalidFileReferences() {
32  return array(
33  'not within PATH_site' => array('/tmp/TYPO3-DataSubmissionControllerTest'),
34  'does not start with upload_temp_' => array(PATH_site . 'typo3temp/foo'),
35  'directory traversal' => array(PATH_site . 'typo3temp/../typo3temp/upload_temp_foo'),
36  );
37  }
38 
44  if (TYPO3_OS === 'WIN') {
45  $this->markTestSkipped('destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory() test not available on Windows.');
46  }
47 
48  // Create test file
49  touch($file);
50  if (!is_file($file)) {
51  $this->markTestSkipped('destructorDoesNotRemoveFilesNotWithinTypo3TempDirectory() skipped: Test file could not be created');
52  }
53 
54  $instance = new \TYPO3\CMS\Frontend\Controller\DataSubmissionController(999999999, $lockMethod);
55  $t3libLockReflection = new \ReflectionClass('TYPO3\\CMS\\Frontend\\Controller\\DataSubmissionController');
56  $t3libLockReflectionResourceProperty = $t3libLockReflection->getProperty('temporaryFiles');
57  $t3libLockReflectionResourceProperty->setAccessible(TRUE);
58  $t3libLockReflectionResourceProperty->setValue($instance, array($file));
59 
60  // Call release method
61  $instance->__destruct();
62 
63  // Check if file is still there and clean up
64  $fileExists = is_file($file);
65  if (is_file($file)) {
66  unlink($file);
67  }
68 
69  $this->assertTrue($fileExists);
70  }
71 }