function SectionStorageManagerTest::testFindDefinitions

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php \Drupal\Tests\layout_builder\Unit\SectionStorageManagerTest::testFindDefinitions()
  2. 8.9.x core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php \Drupal\Tests\layout_builder\Unit\SectionStorageManagerTest::testFindDefinitions()
  3. 11.x core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php \Drupal\Tests\layout_builder\Unit\SectionStorageManagerTest::testFindDefinitions()

@covers ::findDefinitions

File

core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php, line 127

Class

SectionStorageManagerTest
@coversDefaultClass \Drupal\layout_builder\SectionStorage\SectionStorageManager

Namespace

Drupal\Tests\layout_builder\Unit

Code

public function testFindDefinitions() : void {
    $this->discovery
        ->getDefinitions()
        ->willReturn([
        'plugin1' => (new SectionStorageDefinition())->setClass(SectionStorageInterface::class),
        'plugin2' => (new SectionStorageDefinition([
            'weight' => -5,
        ]))->setClass(SectionStorageInterface::class),
        'plugin3' => (new SectionStorageDefinition([
            'weight' => -5,
        ]))->setClass(SectionStorageInterface::class),
        'plugin4' => (new SectionStorageDefinition([
            'weight' => 10,
        ]))->setClass(SectionStorageInterface::class),
    ]);
    $expected = [
        'plugin2',
        'plugin3',
        'plugin1',
        'plugin4',
    ];
    $result = $this->manager
        ->getDefinitions();
    $this->assertSame($expected, array_keys($result));
}

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