You are here

protected function DrupalTest::setMockContainerService in Zircon Profile 8

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

32 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 service() method.
DrupalTest::testConfig in core/tests/Drupal/Tests/Core/DrupalTest.php
Tests the config() method.
DrupalTest::testCsrfToken in core/tests/Drupal/Tests/Core/DrupalTest.php
Tests the csrfToken() method.
DrupalTest::testCurrentUser in core/tests/Drupal/Tests/Core/DrupalTest.php
Tests the currentUser() method.

... See full list

File

core/tests/Drupal/Tests/Core/DrupalTest.php, line 455
Contains \Drupal\Tests\Core\DrupalTest.

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