3 namespace Drupal\Tests\ctools\Unit;
5 use Drupal\Core\Block\BlockManagerInterface;
6 use Drupal\Core\Block\BlockPluginInterface;
7 use Drupal\ctools\Plugin\BlockPluginCollection;
8 use Drupal\Tests\UnitTestCase;
12 * Tests the block plugin collection.
14 * @coversDefaultClass \Drupal\ctools\Plugin\BlockPluginCollection
18 class BlockPluginCollectionTest extends UnitTestCase {
21 * Tests the getAllByRegion() method.
23 * @covers ::getAllByRegion
25 public function testGetAllByRegion() {
30 'plugin' => 'system_powered_by_block',
36 'plugin' => 'system_powered_by_block',
42 'plugin' => 'system_powered_by_block',
49 'plugin' => 'system_powered_by_block',
53 $block_manager = $this->prophesize(BlockManagerInterface::class);
55 foreach ($blocks as $block_id => $block) {
56 $plugin = $this->prophesize(BlockPluginInterface::class);
57 $plugin->label()->willReturn($block['label']);
58 $plugin->getConfiguration()->willReturn($block);
59 $plugins[$block_id] = $plugin->reveal();
61 $block_manager->createInstance($block_id, $block)
62 ->willReturn($plugin->reveal())
67 $block_plugin_collection = new BlockPluginCollection($block_manager->reveal(), $blocks);
70 'bing' => $plugins['bing'],
71 'baz' => $plugins['baz'],
72 'foo' => $plugins['foo'],
75 'bar' => $plugins['bar'],
78 $this->assertSame($expected, $block_plugin_collection->getAllByRegion());