public function UnitTestCase::getConfigStorageStub

Returns a stub config storage that returns the supplied configuration.

Parameters

array $configs: An associative array of configuration settings whose keys are configuration object names and whose values are key => value arrays for the configuration object in question.

Return value

\Drupal\Core\Config\StorageInterface A mocked config storage.

1 call to UnitTestCase::getConfigStorageStub()
RolesRidTest::testTitleQuery in drupal/core/modules/user/tests/Drupal/Tests/user/Views/Argument/RolesRidTest.php
Tests the title_query method.

File

drupal/core/tests/Drupal/Tests/UnitTestCase.php, line 122
Contains \Drupal\Tests\UnitTestCase.

Class

UnitTestCase
Provides a base class and helpers for Drupal unit tests.

Namespace

Drupal\Tests

Code

public function getConfigStorageStub(array $configs) {
  $config_storage = $this
    ->getMock('Drupal\\Core\\Config\\NullStorage');
  $config_storage
    ->expects($this
    ->any())
    ->method('listAll')
    ->will($this
    ->returnValue(array_keys($configs)));
  foreach ($configs as $name => $config) {
    $config_storage
      ->expects($this
      ->any())
      ->method('read')
      ->with($this
      ->equalTo($name))
      ->will($this
      ->returnValue($config));
  }
  return $config_storage;
}