You are here

public function RoleSplitFilterTest::testFilterWrite in Config Role Split 8

Test that the filter writes correctly.

@dataProvider filterWriteProvider

File

src/Tests/RoleSplitFilterTest.php, line 21

Class

RoleSplitFilterTest
Class SplitFilterTest.

Namespace

Drupal\config_role_split\Tests

Code

public function testFilterWrite($name, $roles, $data, $existing, $all_expected) {
  foreach ($all_expected as $mode => $expected) {
    $filter = new RoleSplitFilter([
      'mode' => $mode,
      'roles' => $roles,
    ], '', []);

    // Set the source storage to let the filter read the existing data.
    $storage = $this
      ->prophesize(StorageInterface::class);
    $storage
      ->read($name)
      ->willReturn($existing);
    $filter
      ->setSourceStorage($storage
      ->reveal());
    $this
      ->assertEquals($expected, $filter
      ->filterWrite($name, $data), 'Write in ' . $mode . ' mode');
  }
}