You are here

public function MockConfig::__construct in Configuration Update Manager 8

Constructs a mock config object.

Parameters

string $name: Name of the config that is being mocked. Can be blank.

string $entity_prefix: Prefix for the entity type that is being mocked. Often blank.

\Drupal\Tests\config_update\Unit\ConfigUpdateUnitTestBase $test: Test class this comes from.

File

tests/src/Unit/ConfigUpdateUnitTestBase.php, line 443

Class

MockConfig
Mock class for mutable configuration, config entity, and entity storage.

Namespace

Drupal\Tests\config_update\Unit

Code

public function __construct($name, $entity_prefix, ConfigUpdateUnitTestBase $test) {
  $this->name = $name;
  $this->entityPrefix = $entity_prefix;
  $this->test = $test;
  $storage = $test
    ->getConfigStorage();
  if ($name && isset($storage[$name])) {
    $value = $storage[$name];
    $value['is_new'] = FALSE;
  }
  else {
    $value['is_new'] = TRUE;
  }
  $value['_core'] = 'core_for_' . $name;
  $this->value = $value;
}