function RecipeConfigStorageWrapperTest::testReadMultipleStorageA

Test that storage A has precedence over storage B.

File

core/tests/Drupal/Tests/Core/Recipe/RecipeConfigStorageWrapperTest.php, line 167

Class

RecipeConfigStorageWrapperTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Recipe%21RecipeConfigStorageWrapper.php/class/RecipeConfigStorageWrapper/11.x" title="Merges two storages together." class="local">\Drupal\Core\Recipe\RecipeConfigStorageWrapper</a> @group Recipe

Namespace

Drupal\Tests\Core\Recipe

Code

public function testReadMultipleStorageA() : void {
    $a = $this->createMock(StorageInterface::class);
    $a->expects($this->once())
        ->method('readMultiple')
        ->with([
        'a_key',
        'b_key',
    ])
        ->willReturn([
        'a_key' => [
            'a_value',
        ],
    ]);
    $b = $this->createMock(StorageInterface::class);
    $b->expects($this->once())
        ->method('readMultiple')
        ->with([
        'a_key',
        'b_key',
    ])
        ->willReturn([
        'a_key' => [
            'a_conflicting_value',
        ],
        'b_key' => [
            'b_value',
        ],
    ]);
    $storage = new RecipeConfigStorageWrapper($a, $b);
    $this->assertEquals([
        'a_key' => [
            'a_value',
        ],
        'b_key' => [
            'b_value',
        ],
    ], $storage->readMultiple([
        'a_key',
        'b_key',
    ]));
}

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