Skip to content

Commit 0d77aa2

Browse files
committed
Command name changed
1 parent 91aa71b commit 0d77aa2

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class OrdinaryCommand extends Command
8484
protected function configure() : void
8585
{
8686
$this
87-
->setName('command:ordinary')
87+
->setName('command:greeting')
8888
->setDescription('Prints "Hello {config.greeting} {name}')
8989
->setDefinition([
9090
new InputArgument('name', InputArgument::REQUIRED),
@@ -136,6 +136,6 @@ $cli->run();
136136
### 6. Run your command on terminal
137137

138138
```bash
139-
./bin/console command:ordinary Kedibey
139+
./bin/console command:greeting Kedibey
140140
```
141141
Outputs: Hello Dear Kedibey

example/bin/console

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
declare(strict_types=1);
44

55
require_once (__DIR__ . '/../../vendor/autoload.php');
6-
require_once (__DIR__ . '/../../tests/resources/Command/OrdinaryCommand.php');
76

87
use Selami\Console\ApplicationFactory;
98
use Zend\ServiceManager\ServiceManager;
@@ -14,7 +13,7 @@ $container = new ServiceManager([
1413
]);
1514
$container->setService(
1615
'commands', [
17-
SelamiConsoleTest\Command\OrdinaryCommand::class
16+
SelamiConsoleTest\Command\GreetingCommand::class
1817
]
1918
);
2019
$container->setService('config', ['greeting' => 'Dear']);

tests/resources/Command/OrdinaryCommand.php renamed to tests/resources/Command/GreetingCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Symfony\Component\Console\Input\InputArgument;
1111
use Symfony\Component\Console\Output\OutputInterface;
1212

13-
class OrdinaryCommand extends Command
13+
class GreetingCommand extends Command
1414
{
1515
/**
1616
* @var PrintService
@@ -28,8 +28,8 @@ public function __construct(PrintService $printService, array $config, string $n
2828
protected function configure() : void
2929
{
3030
$this
31-
->setName('command:ordinary')
32-
->setDescription('Prints "Hello {config.greeting} {name}')
31+
->setName('command:greeting')
32+
->setDescription('Prints "Hello {config.Greeting} {name}')
3333
->setDefinition([
3434
new InputArgument('name', InputArgument::REQUIRED),
3535
]);

tests/resources/Command/OrdinaryCommandWithArrayDependency.php renamed to tests/resources/Command/GreetingCommandWithArrayDependency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Symfony\Component\Console\Input\InputArgument;
1111
use Symfony\Component\Console\Output\OutputInterface;
1212

13-
class OrdinaryCommandWithArrayDependency extends Command
13+
class GreetingCommandWithArrayDependency extends Command
1414
{
1515
/**
1616
* @var PrintService

tests/resources/Command/OrdinaryCommandWithServiceDependency.php renamed to tests/resources/Command/GreetingCommandWithServiceDependency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Symfony\Component\Console\Input\InputArgument;
1010
use Symfony\Component\Console\Output\OutputInterface;
1111

12-
class OrdinaryCommandWithServiceDependency extends Command
12+
class GreetingCommandWithServiceDependency extends Command
1313
{
1414
/**
1515
* @var NonExistingPrintService

tests/unit/ApplicationFactoryTest.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function successfulConsoleApp() : void
3333
$container->setService(
3434
'commands',
3535
[
36-
SelamiConsoleTest\Command\OrdinaryCommand::class
36+
SelamiConsoleTest\Command\GreetingCommand::class
3737
]
3838
);
3939
$this->container = $container;
@@ -49,18 +49,19 @@ protected function failedConsoleApp() : void
4949
$container->setService(
5050
'config',
5151
[
52-
'cache' => '/tmp/uRt48sl'
52+
'greeting' => 'Dear'
5353
]
5454
);
5555
$container->setService(
5656
'commands',
5757
[
58-
SelamiConsoleTest\Command\OrdinaryCommand::class,
59-
SelamiConsoleTest\Command\OrdinaryCommandWithArrayDependency::class,
58+
SelamiConsoleTest\Command\GreetingCommand::class,
59+
SelamiConsoleTest\Command\GreetingCommandWithArrayDependency::class,
6060
]
6161
);
6262
$this->container = $container;
6363
}
64+
6465
protected function failedForNonExistingServiceConsoleApp() : void
6566
{
6667
$container = new ServiceManager([
@@ -77,8 +78,8 @@ protected function failedForNonExistingServiceConsoleApp() : void
7778
$container->setService(
7879
'commands',
7980
[
80-
SelamiConsoleTest\Command\OrdinaryCommand::class,
81-
SelamiConsoleTest\Command\OrdinaryCommandWithServiceDependency::class,
81+
SelamiConsoleTest\Command\GreetingCommand::class,
82+
SelamiConsoleTest\Command\GreetingCommandWithServiceDependency::class,
8283
]
8384
);
8485
$this->container = $container;
@@ -94,14 +95,15 @@ protected function _after()
9495
public function shouldRunCommandSuccessfully() : void
9596
{
9697
$this->successfulConsoleApp();
97-
$input = new ArrayInput(array('command '=> 'command:ordinary', 'name' => 'Kedibey'));
9898
$cli = Console\ApplicationFactory::makeApplication($this->container, 'TestApp', '1.0.1');
9999
$cli->setAutoExit(false);
100100
$this->assertEquals('TestApp', $cli->getName());
101101
$this->assertEquals('1.0.1', $cli->getVersion());
102+
$input = new ArrayInput(['command'=> 'command:greeting', 'name' => 'Kedibey']);
102103
$output = new BufferedOutput();
103104
$cli->run($input, $output);
104105
$return = $output->fetch();
106+
var_dump($return);
105107
$this->assertEquals('Hello Dear Kedibey' . PHP_EOL, $return);
106108
}
107109

@@ -112,7 +114,7 @@ public function shouldRunCommandSuccessfully() : void
112114
public function shouldFailNonExistingArrayDependency() : void
113115
{
114116
$this->failedConsoleApp();
115-
$input = new ArrayInput(array('command'=>'command:ordinary-with-array-dependency', 'name' => 'world'));
117+
$input = new ArrayInput(array('command'=>'command:greeting-with-array-dependency', 'name' => 'world'));
116118
$cli = Console\ApplicationFactory::makeApplication($this->container, 'TestApp', '1.0.1');
117119
$cli->setAutoExit(false);
118120
$this->assertEquals('TestApp', $cli->getName());
@@ -127,7 +129,7 @@ public function shouldFailNonExistingArrayDependency() : void
127129
public function shouldFailNonExistingServiceDependency() : void
128130
{
129131
$this->failedForNonExistingServiceConsoleApp();
130-
$input = new ArrayInput(array('command'=>'command:ordinary-with-service-dependency', 'name' => 'world'));
132+
$input = new ArrayInput(array('command'=>'command:greeting-with-service-dependency', 'name' => 'world'));
131133
$cli = Console\ApplicationFactory::makeApplication($this->container, 'TestApp', '1.0.1');
132134
$cli->setAutoExit(false);
133135
$this->assertEquals('TestApp', $cli->getName());
@@ -142,7 +144,7 @@ public function shouldFailNonExistingServiceDependency() : void
142144
public function shouldFailNonExistingSCommandDependency() : void
143145
{
144146
$this->failedForNonExistingServiceConsoleApp();
145-
$input = new ArrayInput(array('command'=>'command:ordinary-with-service-dependency', 'name' => 'world'));
147+
$input = new ArrayInput(array('command'=>'command:greeting-with-service-dependency', 'name' => 'world'));
146148
$cli = Console\ApplicationFactory::makeApplication($this->container, 'TestApp', '1.0.1');
147149
$cli->setAutoExit(false);
148150
$this->assertEquals('TestApp', $cli->getName());

0 commit comments

Comments
 (0)