You are here

protected function ConfigIgnorePatternResolverTest::getIgnoredConfigs in Config Ignore 8.3

Returns all ignored configs by expanding the wildcards.

Basically, it provides mocked services and it's a wrapper around the protected method ConfigIgnoreEventSubscriber::getIgnoredConfigs().

Parameters

array $ignore_config_patterns: A list of config ignore patterns.

array $all_configs: A list of names of all configs.

Return value

array A list of ignored configs as is returned by ConfigIgnoreEventSubscriber::getIgnoredConfigs()

Throws

\ReflectionException If the class does not exist.

See also

\Drupal\config_ignore\EventSubscriber\ConfigIgnoreEventSubscriber::getIgnoredConfigs()

2 calls to ConfigIgnorePatternResolverTest::getIgnoredConfigs()
ConfigIgnorePatternResolverTest::testGetIgnoredConfigs in tests/src/Unit/ConfigIgnorePatternResolverTest.php
Tests the config ignore pattern resolver.
ConfigIgnorePatternResolverTest::testInvalidPattern in tests/src/Unit/ConfigIgnorePatternResolverTest.php
Tests the config ignore pattern resolver with an invalid patterns.

File

tests/src/Unit/ConfigIgnorePatternResolverTest.php, line 159

Class

ConfigIgnorePatternResolverTest
Tests the config ignore pattern resolver.

Namespace

Drupal\Tests\config_ignore\Unit

Code

protected function getIgnoredConfigs(array $ignore_config_patterns, array $all_configs) {
  $configIgnoreSettings = $this
    ->prophesize(ImmutableConfig::class);
  $configIgnoreSettings
    ->get('ignored_config_entities')
    ->willReturn($ignore_config_patterns);
  $configFactory = $this
    ->prophesize(ConfigFactoryInterface::class);
  $configFactory
    ->get('config_ignore.settings')
    ->willReturn($configIgnoreSettings
    ->reveal());
  $transformation_storage = $this
    ->prophesize(StorageInterface::class);
  $transformation_storage
    ->listAll()
    ->willReturn($all_configs);
  $subscriber = new ConfigIgnoreEventSubscriber($configFactory
    ->reveal(), $this
    ->prophesize(ModuleHandlerInterface::class)
    ->reveal(), $this
    ->prophesize(StorageInterface::class)
    ->reveal(), $this
    ->prophesize(StorageInterface::class)
    ->reveal());

  // Make ConfigIgnoreEventSubscriber::getIgnoredConfigs() accessible.
  $class = new \ReflectionClass($subscriber);
  $getIgnoredConfigsMethod = $class
    ->getMethod('getIgnoredConfigs');
  $getIgnoredConfigsMethod
    ->setAccessible(TRUE);
  return $getIgnoredConfigsMethod
    ->invokeArgs($subscriber, [
    $transformation_storage
      ->reveal(),
  ]);
}