You are here

public function RoleSplitFilterTest::testFilterRead in Config Role Split 8

Test that the filter reads correctly.

@dataProvider filterReadProvider

File

src/Tests/RoleSplitFilterTest.php, line 88

Class

RoleSplitFilterTest
Class SplitFilterTest.

Namespace

Drupal\config_role_split\Tests

Code

public function testFilterRead($mode, $roles, $name, $data, $expected) {
  $filter = new RoleSplitFilter([
    'mode' => $mode,
    'roles' => $roles,
  ], '', []);
  $this
    ->assertEquals($expected, $filter
    ->filterRead($name, $data));

  // Test that the mode and roles are read from the storage first.
  $storage = $this
    ->prophesize(StorageInterface::class);
  $storage
    ->read('role_split.test')
    ->willReturn([
    'mode' => $mode,
    'roles' => $roles,
  ]);
  $filter = new RoleSplitFilter([
    'config_name' => 'role_split.test',
  ], '', []);
  $filter
    ->setFilteredStorage($storage
    ->reveal());
  $this
    ->assertEquals($expected, $filter
    ->filterRead($name, $data));
}