示例#1
0
 public function __construct($outputId)
 {
     if (!Filesystem::isValidFilename($outputId)) {
         throw new \Exception('The given output id has an invalid format');
     }
     $dir = CliMulti::getTmpPath();
     Filesystem::mkdir($dir);
     $this->tmpFile = $dir . '/' . $outputId . '.output';
 }
示例#2
0
 public function __construct($pid)
 {
     if (!Filesystem::isValidFilename($pid)) {
         throw new \Exception('The given pid has an invalid format');
     }
     $pidDir = CliMulti::getTmpPath();
     Filesystem::mkdir($pidDir);
     $this->isSupported = self::isSupported();
     $this->pidFile = $pidDir . '/' . $pid . '.pid';
     $this->timeCreation = time();
     $this->markAsNotStarted();
 }
示例#3
0
 public function test_cleanupNotRemovedFiles_shouldOnlyRemoveFiles_IfTheyAreOlderThanOneWeek()
 {
     $timeOneWeekAgo = strtotime('-1 week');
     // make sure -1 week returns a timestamp one week ago
     $this->assertGreaterThan(604797, time() - $timeOneWeekAgo);
     $this->assertLessThan(604803, time() - $timeOneWeekAgo);
     $tmpDir = CliMulti::getTmpPath() . '/';
     touch($tmpDir . 'now.pid');
     touch($tmpDir . 'now.output');
     touch($tmpDir . 'toberemoved.pid', $timeOneWeekAgo - 10);
     touch($tmpDir . 'toberemoved.output', $timeOneWeekAgo - 10);
     touch($tmpDir . 'toBeNotRemoved.pid', $timeOneWeekAgo + 10);
     touch($tmpDir . 'toBeNotRemoved.output', $timeOneWeekAgo + 10);
     CliMulti::cleanupNotRemovedFiles();
     $this->assertFileExists($tmpDir . 'now.pid');
     $this->assertFileExists($tmpDir . 'now.output');
     $this->assertFileExists($tmpDir . 'toBeNotRemoved.output');
     $this->assertFileExists($tmpDir . 'toBeNotRemoved.output');
     $this->assertFileNotExists($tmpDir . 'toberemoved.output');
     $this->assertFileNotExists($tmpDir . 'toberemoved.output');
 }