You are here

public function RoleSplitFilterTest::testFilterReadMultiple in Config Role Split 8

Test that the filter reads multiple objects correctly.

File

src/Tests/RoleSplitFilterTest.php, line 103

Class

RoleSplitFilterTest
Class SplitFilterTest.

Namespace

Drupal\config_role_split\Tests

Code

public function testFilterReadMultiple() {
  foreach ([
    'split',
    'fork',
    'exclude',
  ] as $mode) {
    $names = [];
    $all_data = [];
    $all_expected = [];

    // Test by filtering the test data from the read provider.
    foreach ($this
      ->filterReadProvider() as $row) {
      list($row_mode, $roles, $name, $data, $expected) = $row;
      if ($row_mode == $mode) {
        $names[] = $name;
        $all_data[$name] = $data;
        $all_expected[$name] = $expected;
      }
    }

    // The roles are from the last provided example.
    $filter = new RoleSplitFilter([
      'mode' => $mode,
      'roles' => $roles,
    ], '', []);
    $this
      ->assertEquals($all_expected, $filter
      ->filterReadMultiple($names, $all_data));
  }
}