You are here

protected function DrupalTest::setMockContainerService in Drupal 9

Same name and namespace in other branches
  1. 8 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.

31 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.

... See full list

File

core/tests/Drupal/Tests/Core/DrupalTest.php, line 444

Class

DrupalTest
Tests the Drupal class.

Namespace

Drupal\Tests\Core

Code

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);
}