/** * @depend test_doAdvance * @covers ::onAdvance */ public function test_onAdvance() { // Set up monitors $Called = 0; $Steps = 0; // Valid arguments $this->Compiler->onAdvance(function ($Event) use(&$Called, &$Steps) { $Called++; $Steps = $Event->Steps; }); $this->Compiler->doAdvance(-1); $this->assertEquals(1, $Called, 'Compiler::onAdvance() Failed to register callback'); $this->assertEquals(-1, $Steps, 'Compiler::onAdvance() Failed to register callback'); // Invalid arguments try { $this->Compiler->onAdvance(NULL); $this->fail('Failed to generate exception with invalid arguments'); } catch (InvalidArgumentException $e) { } // No mediator $this->Compiler->clearMediator(); $this->Compiler->onAdvance(function () { }); $this->assertEquals(1, $Called, 'Compiler::onAdvance() Failed to register callback'); }
$Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/psr/log/Psr')), 'php'); $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/psr/log/LICENSE'))); $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/symfony')), 'php'); $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE'))); $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE'))); // Thank you zend. Yours is truly the best library $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/zendframework')), 'php'); $Output->overwrite('[=-------------------------------------------------]'); // Compile files $Compiler->onAdvance(function ($Event) use(&$Output) { static $Total = 0; static $Percent = 1; // Add count $Total += $Event->Steps; // Check count if ($Total > 100) { // Reset $Total = $Total % 100; // Advance $Percent++; $Output->overwrite(substr_replace('[--------------------------------------------------]', str_repeat('=', $Percent), 1, $Percent)); } }); $Output->overwrite('-Packaging files'); $Output->write("\r\n[=-------------------------------------------------]"); $Compiler->compile('BLW'); unset($Compiler); $Output->overwrite('-Creating archive'); $Output->write("\r\n[========================================----------]"); // Copy assets $TempBuild = BLW_DIR . 'temp' . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR; @mkdir($TempBuild);