protected function UnitTestCase::getClassResolverStub in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::getClassResolverStub()
Returns a stub class resolver.
Return value
\Drupal\Core\DependencyInjection\ClassResolverInterface|\PHPUnit\Framework\MockObject\MockObject The class resolver stub.
3 calls to UnitTestCase::getClassResolverStub()
- EntityResolverManagerTest::setUp in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityResolverManagerTest.php - @covers ::__construct
- EntityTypeManagerTest::setUp in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityTypeManagerTest.php - FormTestBase::setUp in core/
tests/ Drupal/ Tests/ Core/ Form/ FormTestBase.php
File
- core/
tests/ Drupal/ Tests/ UnitTestCase.php, line 264
Class
- UnitTestCase
- Provides a base class and helpers for Drupal unit tests.
Namespace
Drupal\TestsCode
protected function getClassResolverStub() {
$class_resolver = $this
->createMock('Drupal\\Core\\DependencyInjection\\ClassResolverInterface');
$class_resolver
->expects($this
->any())
->method('getInstanceFromDefinition')
->willReturnCallback(function ($class) {
if (is_subclass_of($class, 'Drupal\\Core\\DependencyInjection\\ContainerInjectionInterface')) {
return $class::create(new ContainerBuilder());
}
else {
return new $class();
}
});
return $class_resolver;
}