Skip to content

Commit e303fc0

Browse files
author
Andrew Carter
committed
Breaking Change: Configured defaults for DaemonRunCommand and reordered constructor parameters.
1 parent 202e5bc commit e303fc0

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/Command/DaemonRunCommand.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPFastCGI\FastCGIDaemon\Command;
44

5+
use PHPFastCGI\FastCGIDaemon\DaemonFactory;
56
use PHPFastCGI\FastCGIDaemon\DaemonFactoryInterface;
67
use PHPFastCGI\FastCGIDaemon\KernelInterface;
78
use Symfony\Component\Console\Command\Command;
@@ -12,6 +13,9 @@
1213

1314
class DaemonRunCommand extends Command
1415
{
16+
const DEFAULT_NAME = 'run';
17+
const DEFAULT_DESCRIPTION = 'Run the FastCGI daemon';
18+
1519
/**
1620
* @var DaemonFactoryInterface
1721
*/
@@ -25,13 +29,17 @@ class DaemonRunCommand extends Command
2529
/**
2630
* Constructor.
2731
*
32+
* @param KernelInterface|callable $kernel The kernel to be given to the daemon
33+
* @param DaemonFactoryInterface $daemonFactory The factory to use to create the daemon
2834
* @param string $name The name of the daemon run command
2935
* @param string $description The description of the daemon run command
30-
* @param DaemonFactoryInterface $daemonFactory The factory to use to create the daemon
31-
* @param KernelInterface|callable $kernel The kernel to be given to the daemon
3236
*/
33-
public function __construct($name, $description, DaemonFactoryInterface $daemonFactory, $kernel)
37+
public function __construct($kernel, DaemonFactoryInterface $daemonFactory = null, $name = null, $description = null)
3438
{
39+
$daemonFactory = ($daemonFactory === null) ? new DaemonFactory : $daemonFactory;
40+
$name = ($name === null) ? self::DEFAULT_NAME : $name;
41+
$description = ($description === null) ? self::DEFAULT_DESCRIPTION : $description;
42+
3543
parent::__construct($name);
3644

3745
$this

test/Command/DaemonRunCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DaemonRunCommandTest extends \PHPUnit_Framework_TestCase
2020
*/
2121
public function testInvalidArgumentException()
2222
{
23-
new DaemonRunCommand('name', 'description', new DaemonFactory(), 'not a callable function');
23+
new DaemonRunCommand('not a callable function');
2424
}
2525

2626
/**
@@ -29,7 +29,7 @@ public function testInvalidArgumentException()
2929
*/
3030
public function testOptions()
3131
{
32-
$command = new DaemonRunCommand('name', 'description', new DaemonFactory(), function () { });
32+
$command = new DaemonRunCommand(function () { });
3333

3434
$definition = $command->getDefinition();
3535

@@ -48,7 +48,7 @@ public function testOptions()
4848
*/
4949
public function testInvalidOptions()
5050
{
51-
$command = new DaemonRunCommand('name', 'description', new DaemonFactory(), function () { });
51+
$command = new DaemonRunCommand(function () { });
5252

5353
$input = new ArrayInput(['--host' => '_']);
5454
$output = new NullOutput();
@@ -103,7 +103,7 @@ public function testCreateDefaultDaemon()
103103
->method('createDaemon')
104104
->will($this->returnValue($mockDaemon));
105105

106-
$command = new DaemonRunCommand('name', 'description', $mockDaemonFactory, function () { });
106+
$command = new DaemonRunCommand(function () { }, $mockDaemonFactory);
107107

108108
$command->run($input, $output);
109109
}
@@ -130,7 +130,7 @@ public function testCreateTcpDaemonWithHost()
130130
->with($this->equalTo($kernel), $this->equalTo($port), $this->equalTo($host))
131131
->will($this->returnValue($mockDaemon));
132132

133-
$command = new DaemonRunCommand('name', 'description', $mockDaemonFactory, $kernel);
133+
$command = new DaemonRunCommand($kernel, $mockDaemonFactory);
134134

135135
$command->run($input, $output);
136136
}
@@ -156,7 +156,7 @@ public function testCreateTcpDaemonWithoutHost()
156156
->with($this->equalTo($kernel), $this->equalTo($port), $this->equalTo('localhost'))
157157
->will($this->returnValue($mockDaemon));
158158

159-
$command = new DaemonRunCommand('name', 'description', $mockDaemonFactory, $kernel);
159+
$command = new DaemonRunCommand($kernel, $mockDaemonFactory);
160160

161161
$command->run($input, $output);
162162
}

0 commit comments

Comments
 (0)