Skip to content

[2.0] Allow to mock services when running command #463

@magnetik

Description

@magnetik

Is your feature request related to a problem? Please describe.
I'm "mocking" some services when using the test client. It's something like that:

$client = $this->getClient();
$clientMock = $this->getMockBuilder(Client::class)
		->disableOriginalConstructor()
		->getMock();

$clientMock
	->method('doThings')
	->willReturn(true);

$client->getContainer()->set(Client::class, $clientMock);

Describe the solution you'd like
Instead of running the command directly, a CommandClient could be created (that could be like the "HttpClient", that allows to run any command and access the container before.

Describe alternatives you've considered
Maybe instead of having the ability to reuse the current kernel in protected function runCommand(string $name, array $params = [], bool $reuseKernel = false), it could be useful to provide your own kernel (and use a kernel from createClient ?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions