function clearExpiredFiles(ExpiredFileManager $expiredManager) { $expiredFiles = $expiredManager->getExpiredFileList(); $progressBar = new ProgressBarManager(0, count($expiredFiles)); $progressBar->setFormat(" - Clearing Expired Files: %current%/%max% [%bar%] %percent%%"); foreach ($expiredFiles as $file) { if (file_exists($file)) { unlink($file) and $expiredManager->delete($file); } else { $expiredManager->delete($file); } $progressBar->advance(); } }
if (file_exists(__DIR__ . '/config.php')) { $config = (require __DIR__ . '/config.php'); } else { $config = (require __DIR__ . '/config.default.php'); } $cachedir = $config->cachedir; $packagejson = json_decode(file_get_contents($cachedir . 'packages.json')); $j = 0; $errors = array(); $providerCounter = 1; $numberOfProviders = count((array) $packagejson->{'provider-includes'}); foreach ($packagejson->{'provider-includes'} as $tpl => $provider) { $providerjson = str_replace('%hash%', $provider->sha256, $tpl); $packages = json_decode(file_get_contents($cachedir . $providerjson)); $progressBar = new ProgressBarManager(0, count((array) $packages->providers)); $progressBar->setFormat(" - Package: %current%/%max% [%bar%] %percent%%"); echo " - Check Provider {$providerCounter}/{$numberOfProviders}:\n"; foreach ($packages->providers as $tpl2 => $sha) { if (!file_exists($file = $cachedir . "p/{$tpl2}\${$sha->sha256}.json")) { $errors[] = " - {$tpl}\t{$tpl2} file not exists\n"; } elseif ($sha->sha256 !== hash_file('sha256', $file)) { unlink($file); $errors[] = " - {$tpl}\t{$tpl2}\tsha256 not match: {$sha->sha256}\n"; } else { ++$j; } $progressBar->advance(); } ++$providerCounter; } if (count($errors)) {
/** * Tests ETA */ public function testEta() { $manager = new Manager(0, 10, 120); $manager->setFormat('%eta%'); $advancement = array(0 => time() - 2); $manager->getRegistry()->setValue('advancement', $advancement); $manager->update(1); $this->assertRegExp("/00:00:18\\s+\\r/", ob_get_contents()); }