protected function ProviderManagerTest::getManagerMock in Video Embed Field 8
Same name and namespace in other branches
- 8.2 tests/src/Unit/ProviderManagerTest.php \Drupal\Tests\video_embed_field\Unit\ProviderManagerTest::getManagerMock()
Get a mock provider manager.
File
- tests/
src/ Unit/ ProviderManagerTest.php, line 103
Class
- ProviderManagerTest
- Tests the provider manager is working.
Namespace
Drupal\Tests\video_embed_field\UnitCode
protected function getManagerMock() {
$definitions = $this->mockProviders;
$manager = $this
->getMockBuilder('Drupal\\video_embed_field\\ProviderManager')
->disableOriginalConstructor()
->setMethods([
'getDefinitions',
'getDefinition',
'createInstance',
])
->getMock();
$manager
->method('getDefinitions')
->willReturn($definitions);
$manager
->method('getDefinition')
->willReturnCallback(function ($value) use ($definitions) {
return $definitions[$value];
});
$manager
->method('createInstance')
->willReturnCallback(function ($name) {
return (object) [
'id' => $name,
];
});
return $manager;
}