From 0d77aa2d6f99cc635ee699eed274260e0868285a Mon Sep 17 00:00:00 2001 From: Mehmet Korkmaz Date: Fri, 30 Nov 2018 23:08:07 +0300 Subject: [PATCH] Command name changed --- README.md | 4 ++-- example/bin/console | 3 +-- ...rdinaryCommand.php => GreetingCommand.php} | 6 ++--- ...=> GreetingCommandWithArrayDependency.php} | 2 +- ... GreetingCommandWithServiceDependency.php} | 2 +- tests/unit/ApplicationFactoryTest.php | 22 ++++++++++--------- 6 files changed, 20 insertions(+), 19 deletions(-) rename tests/resources/Command/{OrdinaryCommand.php => GreetingCommand.php} (88%) rename tests/resources/Command/{OrdinaryCommandWithArrayDependency.php => GreetingCommandWithArrayDependency.php} (95%) rename tests/resources/Command/{OrdinaryCommandWithServiceDependency.php => GreetingCommandWithServiceDependency.php} (95%) diff --git a/README.md b/README.md index 7acf3af..141c61c 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ class OrdinaryCommand extends Command protected function configure() : void { $this - ->setName('command:ordinary') + ->setName('command:greeting') ->setDescription('Prints "Hello {config.greeting} {name}') ->setDefinition([ new InputArgument('name', InputArgument::REQUIRED), @@ -136,6 +136,6 @@ $cli->run(); ### 6. Run your command on terminal ```bash -./bin/console command:ordinary Kedibey +./bin/console command:greeting Kedibey ``` Outputs: Hello Dear Kedibey diff --git a/example/bin/console b/example/bin/console index 3c228d6..109b183 100755 --- a/example/bin/console +++ b/example/bin/console @@ -3,7 +3,6 @@ declare(strict_types=1); require_once (__DIR__ . '/../../vendor/autoload.php'); -require_once (__DIR__ . '/../../tests/resources/Command/OrdinaryCommand.php'); use Selami\Console\ApplicationFactory; use Zend\ServiceManager\ServiceManager; @@ -14,7 +13,7 @@ $container = new ServiceManager([ ]); $container->setService( 'commands', [ - SelamiConsoleTest\Command\OrdinaryCommand::class + SelamiConsoleTest\Command\GreetingCommand::class ] ); $container->setService('config', ['greeting' => 'Dear']); diff --git a/tests/resources/Command/OrdinaryCommand.php b/tests/resources/Command/GreetingCommand.php similarity index 88% rename from tests/resources/Command/OrdinaryCommand.php rename to tests/resources/Command/GreetingCommand.php index 0d40ead..f8e4d1b 100644 --- a/tests/resources/Command/OrdinaryCommand.php +++ b/tests/resources/Command/GreetingCommand.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -class OrdinaryCommand extends Command +class GreetingCommand extends Command { /** * @var PrintService @@ -28,8 +28,8 @@ public function __construct(PrintService $printService, array $config, string $n protected function configure() : void { $this - ->setName('command:ordinary') - ->setDescription('Prints "Hello {config.greeting} {name}') + ->setName('command:greeting') + ->setDescription('Prints "Hello {config.Greeting} {name}') ->setDefinition([ new InputArgument('name', InputArgument::REQUIRED), ]); diff --git a/tests/resources/Command/OrdinaryCommandWithArrayDependency.php b/tests/resources/Command/GreetingCommandWithArrayDependency.php similarity index 95% rename from tests/resources/Command/OrdinaryCommandWithArrayDependency.php rename to tests/resources/Command/GreetingCommandWithArrayDependency.php index a2977c3..4bc137b 100644 --- a/tests/resources/Command/OrdinaryCommandWithArrayDependency.php +++ b/tests/resources/Command/GreetingCommandWithArrayDependency.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -class OrdinaryCommandWithArrayDependency extends Command +class GreetingCommandWithArrayDependency extends Command { /** * @var PrintService diff --git a/tests/resources/Command/OrdinaryCommandWithServiceDependency.php b/tests/resources/Command/GreetingCommandWithServiceDependency.php similarity index 95% rename from tests/resources/Command/OrdinaryCommandWithServiceDependency.php rename to tests/resources/Command/GreetingCommandWithServiceDependency.php index 33e4310..c2b7c00 100644 --- a/tests/resources/Command/OrdinaryCommandWithServiceDependency.php +++ b/tests/resources/Command/GreetingCommandWithServiceDependency.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -class OrdinaryCommandWithServiceDependency extends Command +class GreetingCommandWithServiceDependency extends Command { /** * @var NonExistingPrintService diff --git a/tests/unit/ApplicationFactoryTest.php b/tests/unit/ApplicationFactoryTest.php index 47eca15..5c23cce 100644 --- a/tests/unit/ApplicationFactoryTest.php +++ b/tests/unit/ApplicationFactoryTest.php @@ -33,7 +33,7 @@ protected function successfulConsoleApp() : void $container->setService( 'commands', [ - SelamiConsoleTest\Command\OrdinaryCommand::class + SelamiConsoleTest\Command\GreetingCommand::class ] ); $this->container = $container; @@ -49,18 +49,19 @@ protected function failedConsoleApp() : void $container->setService( 'config', [ - 'cache' => '/tmp/uRt48sl' + 'greeting' => 'Dear' ] ); $container->setService( 'commands', [ - SelamiConsoleTest\Command\OrdinaryCommand::class, - SelamiConsoleTest\Command\OrdinaryCommandWithArrayDependency::class, + SelamiConsoleTest\Command\GreetingCommand::class, + SelamiConsoleTest\Command\GreetingCommandWithArrayDependency::class, ] ); $this->container = $container; } + protected function failedForNonExistingServiceConsoleApp() : void { $container = new ServiceManager([ @@ -77,8 +78,8 @@ protected function failedForNonExistingServiceConsoleApp() : void $container->setService( 'commands', [ - SelamiConsoleTest\Command\OrdinaryCommand::class, - SelamiConsoleTest\Command\OrdinaryCommandWithServiceDependency::class, + SelamiConsoleTest\Command\GreetingCommand::class, + SelamiConsoleTest\Command\GreetingCommandWithServiceDependency::class, ] ); $this->container = $container; @@ -94,14 +95,15 @@ protected function _after() public function shouldRunCommandSuccessfully() : void { $this->successfulConsoleApp(); - $input = new ArrayInput(array('command '=> 'command:ordinary', 'name' => 'Kedibey')); $cli = Console\ApplicationFactory::makeApplication($this->container, 'TestApp', '1.0.1'); $cli->setAutoExit(false); $this->assertEquals('TestApp', $cli->getName()); $this->assertEquals('1.0.1', $cli->getVersion()); + $input = new ArrayInput(['command'=> 'command:greeting', 'name' => 'Kedibey']); $output = new BufferedOutput(); $cli->run($input, $output); $return = $output->fetch(); + var_dump($return); $this->assertEquals('Hello Dear Kedibey' . PHP_EOL, $return); } @@ -112,7 +114,7 @@ public function shouldRunCommandSuccessfully() : void public function shouldFailNonExistingArrayDependency() : void { $this->failedConsoleApp(); - $input = new ArrayInput(array('command'=>'command:ordinary-with-array-dependency', 'name' => 'world')); + $input = new ArrayInput(array('command'=>'command:greeting-with-array-dependency', 'name' => 'world')); $cli = Console\ApplicationFactory::makeApplication($this->container, 'TestApp', '1.0.1'); $cli->setAutoExit(false); $this->assertEquals('TestApp', $cli->getName()); @@ -127,7 +129,7 @@ public function shouldFailNonExistingArrayDependency() : void public function shouldFailNonExistingServiceDependency() : void { $this->failedForNonExistingServiceConsoleApp(); - $input = new ArrayInput(array('command'=>'command:ordinary-with-service-dependency', 'name' => 'world')); + $input = new ArrayInput(array('command'=>'command:greeting-with-service-dependency', 'name' => 'world')); $cli = Console\ApplicationFactory::makeApplication($this->container, 'TestApp', '1.0.1'); $cli->setAutoExit(false); $this->assertEquals('TestApp', $cli->getName()); @@ -142,7 +144,7 @@ public function shouldFailNonExistingServiceDependency() : void public function shouldFailNonExistingSCommandDependency() : void { $this->failedForNonExistingServiceConsoleApp(); - $input = new ArrayInput(array('command'=>'command:ordinary-with-service-dependency', 'name' => 'world')); + $input = new ArrayInput(array('command'=>'command:greeting-with-service-dependency', 'name' => 'world')); $cli = Console\ApplicationFactory::makeApplication($this->container, 'TestApp', '1.0.1'); $cli->setAutoExit(false); $this->assertEquals('TestApp', $cli->getName());