You are here

public function ConfigImporterServiceTest::testFilter in Config Importer and Tools 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/ConfigImporterServiceTest.php \Drupal\Tests\config_import\Unit\ConfigImporterServiceTest::testFilter()

Check that configuration will or will not be filtered.

@dataProvider providerFilter

@covers \Drupal\config_import\ConfigImporterService::export @covers \Drupal\config_import\ConfigImporterService::filter

Parameters

bool $should_be_filtered: Indicates that configuration must or must not be filtered.

File

tests/src/Unit/ConfigImporterServiceTest.php, line 58

Class

ConfigImporterServiceTest
Testing configuration importer service.

Namespace

Drupal\Tests\config_import\Unit

Code

public function testFilter($should_be_filtered) {
  if ($should_be_filtered) {

    // The next module contains an alteration hook which will
    // deny importing of configuration.
    $this
      ->enableModules([
      'config_import_test',
    ]);
  }

  // Construct intermediate files storage.
  $tmp_storage = new FileStorage("{$this->siteDirectory}/confi");

  // Initially we will export all configurations from active storage (it's
  // database usually) into temporary files storage. Then the "filter" method
  // will try to clean temporary storage and deny importing of some configs.
  // WARNING: an order of executions must not be changed!
  foreach ([
    'export',
    'filter',
  ] as $method) {
    static::assertNull($this
      ->invokeMethod($method, $tmp_storage));
  }
  static::assertSame(!$should_be_filtered, $tmp_storage
    ->exists(static::TEST_CONFIG));
}