АА
Size: a a a
АА
✨
АА
✨
КА
VM
КА
VM
class TestApiClient implements ApiClientInterface {
public ApiClientInterface $wrapped;
public function someApiMethod() {
$this->wrapped->someApiMethod();
}
}$mock = $this->createMock(ApiClientInterface::class);
// configure mock
$wrapper = $client->getContainer()->get(TestApiClient::class);
$wrapper->wrapped = $mock;
VM
VM
КА
$container = static::$container;
$fetcherMock = $this->getMockBuilder(CommentFetcher::class)
->disableOriginalConstructor()
->onlyMethods(['fetch'])
->getMock();
$fetcherMock
->method('fetch')
->withAnyParameters()
->willReturn($result);
$container->set('App\Component\Comment\CommentFetcher', $fetcherMock);КА
App\Component\Comment\CommentFetcher делаю публичным в services_test.yamlКА
КА
AD
КА