function ConfigExportCommandTest::assertStorageEquals
Asserts that two config storage objects have the same content.
Parameters
\Drupal\Core\Config\StorageInterface $expected: The storage with the expected data.
\Drupal\Core\Config\StorageInterface $actual: The storage with the actual data.
string $message: The message to add to the assertion.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigExportCommandTest.php, line 170
Class
- ConfigExportCommandTest
- Tests the 'config:export' command.
Namespace
Drupal\KernelTests\Core\ConfigCode
protected static function assertStorageEquals(StorageInterface $expected, StorageInterface $actual, string $message = '') : void {
// The same collections have to exist.
static::assertEqualsCanonicalizing($expected->getAllCollectionNames(), $actual->getAllCollectionNames(), $message);
// Now loop over all collections and assert the data to be equal.
foreach (array_merge([
StorageInterface::DEFAULT_COLLECTION,
], $expected->getAllCollectionNames()) as $collection) {
$expected_collection = $expected->createCollection($collection);
$actual_collection = $actual->createCollection($collection);
// The same names are present in both.
static::assertEqualsCanonicalizing($expected_collection->listAll(), $actual_collection->listAll(), $message);
foreach ($expected_collection->listAll() as $name) {
// The same data can be read from both.
static::assertEquals($expected_collection->read($name), $actual_collection->read($name), $message . ' ' . $name);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.