$tempDir = new \r8\FileSys\Dir(rtrim(sys_get_temp_dir(), "/") . "/RoundEights_" . uniqid()); } while ($tempDir->isDir()); // Pull the destination directory that the package will be pooled in $dest = new \r8\FileSys\Dir($tempDir->getSubPath("RoundEights")->getPath()); // Create the destination dir $dest->make(); echo "Temporary directory created: " . $dest->getPath() . "\n"; // Pull a list of dirs and files that need to be copied and their destination $copy = array("src" => "", "tests" => "", "README.md" => "README.txt", "LICENSE.md" => "LICENSE.txt", "tools/RoundEights-" . r8_VERSION . ".phar" => ""); // Copy the above files foreach ($copy as $source => $destination) { echo "Copying: " . $source . " "; if (!file_exists($base . $source)) { die("\nCould not locate required path: " . $base . $source); } $result = system("cp -R " . escapeshellarg($base . $source) . " " . escapeshellarg($dest->getSubPath($destination)->getPath())); if ($result === FALSE) { die("Failed"); } echo "complete\n"; } // Remove the config file from pooled directory if ($dest->contains("tests/config.php")) { $dest->getSubPath("tests/config.php")->delete(); echo "test config file deleted\n"; } $zipFile = new \r8\FileSys\File($base . "tools/RoundEights-" . r8_VERSION . ".zip"); $targzFile = new \r8\FileSys\File($base . "tools/RoundEights-" . r8_VERSION . ".tar.gz"); if ($zipFile->exists()) { echo "Removing existing zip file\n"; $zipFile->delete();
public function testGetSubPath_doesntExist() { $dir = new \r8\FileSys\Dir($this->dir); $result = $dir->getSubPath("notAFile"); $this->assertThat($result, $this->isInstanceOf('r8\\FileSys\\File')); $this->assertSame($this->dir . "/notAFile", $result->getPath()); $result = $dir->getSubPath("/dir/to/a/non/existant/file"); $this->assertThat($result, $this->isInstanceOf('r8\\FileSys\\File')); $this->assertSame("/dir/to/a/non/existant/file", $result->getPath()); }