public function testExecuteListsCommandsWithNamespaceArgument() { require_once realpath(__DIR__ . '/../Fixtures/FooCommand.php'); $application = new Application(); $application->add(new \FooCommand()); $commandTester = new CommandTester($command = $application->get('list')); $parsedCommand = $commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true)); /** @var $parsedCommand ParsedCommand */ $injector = new \Auryn\Provider(); $injector->execute($parsedCommand->getCallable()); $output = <<<EOF foo:bar The foo:bar command EOF; $this->assertEquals($output, $commandTester->getDisplay(true)); }
\ImagickDemo\ImagickPixel\functions::load(); \ImagickDemo\ImagickPixelIterator\functions::load(); \ImagickDemo\Tutorial\functions::load(); $examples = (require_once "../imagick/test.data.php"); foreach ($examples as $example) { set_time_limit(30); list($function, $params) = $example; $injector = new Auryn\Provider(); $lowried = []; foreach ($params as $key => $value) { $lowried[':' . $key] = $value; } try { echo "function {$function} \n"; ob_start(); $injector->execute($function, $lowried); $contents = ob_get_contents(); ob_end_clean(); $filename = str_replace('\\', '_', $function); $paramString = ''; foreach ($params as $key => $value) { $paramString = md5($paramString . $key); $paramString = md5($paramString . $value); } global $imageType; $extension = $imageType; $fullFilename = sprintf("cliTest/%s_%s.%s", $filename, $paramString, $extension); file_put_contents($fullFilename, $contents); } catch (\Exception $e) { ob_end_clean(); echo "Excaption caught: " . $e->getMessage() . "\n";
{ $newParams = []; foreach ($params as $key => $value) { $newParams[':' . $key] = $value; } return $newParams; } $console = new Application(); $console->add(new AboutCommand()); $uploadCommand = new Command('upload', 'uploadFile'); $uploadCommand->addArgument('filename', InputArgument::REQUIRED, 'The name of the file to upload'); $uploadCommand->addOption('dir', null, InputArgument::OPTIONAL, 'Which directory to upload from', './'); $console->add($uploadCommand); $helloWorldCallable = function ($name) { echo "Hello world, and particularly {$name}" . PHP_EOL; }; $callableCommand = new Command('greet', $helloWorldCallable); $callableCommand->addArgument('name', InputArgument::REQUIRED, 'The name of the person to say hello to.'); $callableCommand->setDescription("Says hello to the world and one named person"); $console->add($callableCommand); try { $parsedCommand = $console->parseCommandLine(); } catch (\Exception $e) { $output = new BufferedOutput(); $console->renderException($e, $output); echo $output->fetch(); exit(-1); } $provider = new Auryn\Provider(); $provider->execute($parsedCommand->getCallable(), lowrey($parsedCommand->getParams()));