function DrupalTest::setMockContainerService
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::setMockContainerService()
- 10 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::setMockContainerService()
- 11.x core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::setMockContainerService()
Sets up a mock expectation for the container get() method.
Parameters
string $service_name: The service name to expect for the get() method.
mixed $return: The value to return from the mocked container get() method.
34 calls to DrupalTest::setMockContainerService()
- DrupalTest::testAccessManager in core/
tests/ Drupal/ Tests/ Core/ DrupalTest.php - Tests the accessManager() method.
- DrupalTest::testCache in core/
tests/ Drupal/ Tests/ Core/ DrupalTest.php - Tests the cache() method.
- DrupalTest::testClassResolver in core/
tests/ Drupal/ Tests/ Core/ DrupalTest.php - Tests the classResolver method.
- DrupalTest::testClassResolverWithClass in core/
tests/ Drupal/ Tests/ Core/ DrupalTest.php - Tests the classResolver method when called with a class.
- DrupalTest::testConfig in core/
tests/ Drupal/ Tests/ Core/ DrupalTest.php - Tests the config() method.
File
-
core/
tests/ Drupal/ Tests/ Core/ DrupalTest.php, line 504
Class
- DrupalTest
- Tests the Drupal class.
Namespace
Drupal\Tests\CoreCode
protected function setMockContainerService($service_name, $return = NULL) {
$expects = $this->container
->expects($this->once())
->method('get')
->with($service_name);
if (isset($return)) {
$expects->will($this->returnValue($return));
}
else {
$expects->will($this->returnValue(TRUE));
}
\Drupal::setContainer($this->container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.