/** * Tests the static registry methods. * * @return void */ public function testStaticGetSetRegistryMethod() { // Keep current for restore $old = phpucConsoleOutput::get(); $output = new phpucConsoleOutput(); $this->assertNotSame($output, phpucConsoleOutput::get()); phpucConsoleOutput::set($output); $this->assertSame($output, phpucConsoleOutput::get()); // Restore phpucConsoleOutput::set($old); }
/** * Performs a single cli request. * * @return void */ public function run() { try { if ($this->input->parse()) { phpucConsoleOutput::set(new phpucConsoleOutput()); $command = phpucAbstractCommand::createCommand($this->input->args->command); $command->setConsoleArgs($this->input->args); $command->validate(); $command->execute(); } exit(0); } catch (phpucConsoleException $e) { echo $e->getMessage(), PHP_EOL; exit(1); } catch (phpucExecuteException $e) { echo $e->getMessage(), PHP_EOL; exit(2); } catch (phpucValidateException $e) { echo $e->getMessage(), PHP_EOL; exit(3); } catch (phpucRuntimeException $e) { echo $e->getMessage(), PHP_EOL; exit(5); } catch (Exception $e) { echo $e->getMessage(), PHP_EOL; exit(4); } }
/** * Initializes the test environment. * * @return void */ public static function init() { // Load phpUnderControl base class include_once PHPUC_SOURCE . '/PhpUnderControl.php'; include_once PHPUC_SOURCE . '/Util/Autoloader.php'; // Register autoload $autoloader = new phpucAutoloader(); spl_autoload_register(array($autoloader, 'autoload')); // Load ezcBase class if (file_exists(PHPUC_EZC_BASE)) { include_once PHPUC_EZC_BASE; spl_autoload_register(array('ezcBase', 'autoload')); } include_once dirname(__FILE__) . '/ConsoleOutputBuffer.php'; phpucConsoleOutput::set(new phpucConsoleOutputBuffer()); if (!is_dir(PHPUC_TEST_DIR)) { mkdir(PHPUC_TEST_DIR); } self::$windows = phpucFileUtil::getOS() === phpucFileUtil::OS_WINDOWS; }