factory = new ApplicationFactory(); } /** @test */ public function allCommandsWhichAreServicesAreAdded(): void { $sm = $this->createServiceManager([ 'commands' => [ 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz', ], ]); $sm->setService('foo', $this->createCommandMock('foo')->reveal()); $sm->setService('bar', $this->createCommandMock('bar')->reveal()); $instance = ($this->factory)($sm); $this->assertTrue($instance->has('foo')); $this->assertTrue($instance->has('bar')); $this->assertFalse($instance->has('baz')); } private function createServiceManager(array $config = []): ServiceManager { return new ServiceManager(['services' => [ 'config' => [ 'cli' => $config, ], AppOptions::class => new AppOptions(), ]]); } private function createCommandMock(string $name): ObjectProphecy { $command = $this->prophesize(Command::class); $command->getName()->willReturn($name); $command->getDefinition()->willReturn($name); $command->isEnabled()->willReturn(true); $command->getAliases()->willReturn([]); $command->setApplication(Argument::type(Application::class))->willReturn(function () { }); return $command; } }