protected function UnitTestCase::getClassResolverStub in Drupal 8
Same name and namespace in other branches
- 9 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 274
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')
->will($this
->returnCallback(function ($class) {
if (is_subclass_of($class, 'Drupal\\Core\\DependencyInjection\\ContainerInjectionInterface')) {
return $class::create(new ContainerBuilder());
}
else {
return new $class();
}
}));
return $class_resolver;
}