You are here

public function FilteredStorageTest::testReadMultipleWithEmptyResults in Config Filter 8

Same name and namespace in other branches
  1. 8.2 src/Tests/FilteredStorageTest.php \Drupal\config_filter\Tests\FilteredStorageTest::testReadMultipleWithEmptyResults()

Test that when a filter removes config on a readMultiple it is not set.

File

src/Tests/FilteredStorageTest.php, line 187

Class

FilteredStorageTest
Tests StorageWrapper operations using the CachedStorage.

Namespace

Drupal\config_filter\Tests

Code

public function testReadMultipleWithEmptyResults() {
  $names = [
    $this
      ->randomString(),
    $this
      ->randomString(),
  ];
  $source = $this
    ->prophesize(StorageInterface::class);
  $data = [
    $this
      ->randomArray(),
    $this
      ->randomArray(),
  ];
  $source
    ->readMultiple($names)
    ->willReturn($data);
  $source = $source
    ->reveal();
  foreach ([
    0,
    [],
    NULL,
  ] as $none) {
    $filtered = $data;
    $filtered[1] = $none;
    $filter = $this
      ->prophesizeFilter();
    $filter
      ->filterReadMultiple($names, $data)
      ->willReturn($filtered);
    $storage = new FilteredStorage($source, [
      $filter
        ->reveal(),
    ]);
    $this
      ->assertEquals([
      $data[0],
    ], $storage
      ->readMultiple($names));
  }
}