/** * @param $testRoot string Root directory for the test * @param $fileName string Name of the uploaded file * @return string Destination path for the uploaded file */ function getFileDestination($testRoot, $fileName) { if (!isVideoFile($fileName)) { // non-video files are simply copied to the test root return $testRoot . "/" . $fileName; } // put each run of video data in it's own directory $testPaths = TestPaths::fromUnderscoreFileName($testRoot, $fileName); // make sure video dir exists $videoDir = $testPaths->videoDir(); if (!is_dir($videoDir)) { mkdir($videoDir, 0777, true); } return getVideoFilePath($testPaths); }
public function testUnderscoreFilenameParse() { $fn = TestPaths::fromUnderscoreFileName("test", "3_Cached_2_my_base_12.ext"); $this->assertNotNull($fn); $this->assertEquals("my_base_12.ext", $fn->getParsedBaseName()); $this->assertEquals("test/video_3_cached_2", $fn->videoDir()); $fn = TestPaths::fromUnderscoreFileName("test", "3_Cached_ab_4"); $this->assertNotNull($fn); $this->assertEquals("ab_4", $fn->getParsedBaseName()); $this->assertEquals("test/video_3_cached", $fn->videoDir()); $fn = TestPaths::fromUnderscoreFileName("test", "3_2_x"); $this->assertNotNull($fn); $this->assertEquals("x", $fn->getParsedBaseName()); $this->assertEquals("test/video_3_2", $fn->videoDir()); }