|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\Console\Application;
|
16 | 16 | use Symfony\Component\Console\Command\Command;
|
17 |
| -use Symfony\Component\Console\CommandLoader\ContainerCommandLoader; |
| 17 | +use Symfony\Component\Console\CommandLoader\FactoryCommandLoader; |
18 | 18 | use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
19 | 19 | use Symfony\Component\Console\Helper\HelperSet;
|
20 | 20 | use Symfony\Component\Console\Helper\FormatterHelper;
|
|
35 | 35 | use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
36 | 36 | use Symfony\Component\Console\Exception\CommandNotFoundException;
|
37 | 37 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
38 |
| -use Symfony\Component\DependencyInjection\ServiceLocator; |
39 | 38 | use Symfony\Component\EventDispatcher\EventDispatcher;
|
40 | 39 |
|
41 | 40 | class ApplicationTest extends TestCase
|
@@ -129,10 +128,9 @@ public function testAllWithCommandLoader()
|
129 | 128 | $commands = $application->all('foo');
|
130 | 129 | $this->assertCount(1, $commands, '->all() takes a namespace as its first argument');
|
131 | 130 |
|
132 |
| - $application->setCommandLoader(new ContainerCommandLoader( |
133 |
| - new ServiceLocator(array('foo-bar' => function () { return new \Foo1Command(); })), |
134 |
| - array('foo:bar1' => 'foo-bar') |
135 |
| - )); |
| 131 | + $application->setCommandLoader(new FactoryCommandLoader(array( |
| 132 | + 'foo:bar1' => function () { return new \Foo1Command(); }, |
| 133 | + ))); |
136 | 134 | $commands = $application->all('foo');
|
137 | 135 | $this->assertCount(2, $commands, '->all() takes a namespace as its first argument');
|
138 | 136 | $this->assertInstanceOf(\FooCommand::class, $commands['foo:bar'], '->all() returns the registered commands');
|
@@ -202,9 +200,9 @@ public function testHasGetWithCommandLoader()
|
202 | 200 | $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name');
|
203 | 201 | $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias');
|
204 | 202 |
|
205 |
| - $application->setCommandLoader(new ContainerCommandLoader(new ServiceLocator(array( |
206 |
| - 'foo-bar' => function () { return new \Foo1Command(); }, |
207 |
| - )), array('foo:bar1' => 'foo-bar', 'afoobar1' => 'foo-bar'))); |
| 203 | + $application->setCommandLoader(new FactoryCommandLoader(array( |
| 204 | + 'foo:bar1' => function () { return new \Foo1Command(); }, |
| 205 | + ))); |
208 | 206 |
|
209 | 207 | $this->assertTrue($application->has('afoobar'), '->has() returns true if an instance is registered for an alias even with command loader');
|
210 | 208 | $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns an instance by name even with command loader');
|
@@ -321,9 +319,9 @@ public function testFind()
|
321 | 319 | public function testFindWithCommandLoader()
|
322 | 320 | {
|
323 | 321 | $application = new Application();
|
324 |
| - $application->setCommandLoader(new ContainerCommandLoader(new ServiceLocator(array( |
325 |
| - 'foo-bar' => $f = function () { return new \FooCommand(); }, |
326 |
| - )), array('foo:bar' => 'foo-bar'))); |
| 322 | + $application->setCommandLoader(new FactoryCommandLoader(array( |
| 323 | + 'foo:bar' => $f = function () { return new \FooCommand(); }, |
| 324 | + ))); |
327 | 325 |
|
328 | 326 | $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists');
|
329 | 327 | $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists');
|
|
0 commit comments