function StorageComparerTest::testDifferentCollections

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php \Drupal\Tests\Core\Config\StorageComparerTest::testDifferentCollections()
  2. 10 core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php \Drupal\Tests\Core\Config\StorageComparerTest::testDifferentCollections()

@covers ::createChangelist

File

core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php, line 261

Class

StorageComparerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Config%21StorageComparer.php/class/StorageComparer/11.x" title="Defines a config storage comparer." class="local">\Drupal\Core\Config\StorageComparer</a> @group Config

Namespace

Drupal\Tests\Core\Config

Code

public function testDifferentCollections() : void {
    $source = new MemoryStorage();
    $target = new MemoryStorage();
    $this->generateRandomData($source, 's');
    $this->generateRandomData($target, 't');
    // Use random collections for source and target.
    $collections = $source->getAllCollectionNames();
    $source = $source->createCollection($collections[array_rand($collections)]);
    $collections = $target->getAllCollectionNames();
    $target = $target->createCollection($collections[array_rand($collections)]);
    $comparer = new StorageComparer($source, $target);
    $comparer->createChangelist();
    foreach (array_merge([
        StorageInterface::DEFAULT_COLLECTION,
    ], $source->getAllCollectionNames(), $target->getAllCollectionNames()) as $collection) {
        $expected = [
            'create' => $source->createCollection($collection)
                ->listAll(),
            'update' => [],
            'delete' => $target->createCollection($collection)
                ->listAll(),
            'rename' => [],
        ];
        $this->assertEqualsCanonicalizing($expected, $comparer->getChangelist(NULL, $collection));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.