function RecipeConfigStorageWrapperTest::testCreateCollection

Same name in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Recipe/RecipeConfigStorageWrapperTest.php \Drupal\Tests\Core\Recipe\RecipeConfigStorageWrapperTest::testCreateCollection()

Test creating a collection passes the name through to the child storages.

File

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

Class

RecipeConfigStorageWrapperTest
@coversDefaultClass \Drupal\Core\Recipe\RecipeConfigStorageWrapper @group Recipe

Namespace

Drupal\Tests\Core\Recipe

Code

public function testCreateCollection() : void {
    $collection_name = 'collection';
    $a = $this->createMock(StorageInterface::class);
    $b = $this->createMock(StorageInterface::class);
    
    /** @var \PHPUnit\Framework\MockObject\MockObject $mock */
    foreach ([
        $a,
        $b,
    ] as $mock) {
        $mock->expects($this->once())
            ->method('createCollection')
            ->with($collection_name)
            ->willReturn(new NullStorage($collection_name));
    }
    $storage = new RecipeConfigStorageWrapper($a, $b);
    $new = $storage->createCollection($collection_name);
    $this->assertInstanceOf(RecipeConfigStorageWrapper::class, $new);
    $this->assertEquals($collection_name, $new->getCollectionName());
    $this->assertNotEquals($storage, $new);
}

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