X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fctools%2Ftests%2Fsrc%2FUnit%2FBlockPluginCollectionTest.php;fp=web%2Fmodules%2Fcontrib%2Fctools%2Ftests%2Fsrc%2FUnit%2FBlockPluginCollectionTest.php;h=c9281070b26487612ff00a9c7c4c0520aa7a0aca;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/ctools/tests/src/Unit/BlockPluginCollectionTest.php b/web/modules/contrib/ctools/tests/src/Unit/BlockPluginCollectionTest.php new file mode 100644 index 000000000..c9281070b --- /dev/null +++ b/web/modules/contrib/ctools/tests/src/Unit/BlockPluginCollectionTest.php @@ -0,0 +1,81 @@ + [ + 'id' => 'foo', + 'label' => 'Foo', + 'plugin' => 'system_powered_by_block', + 'region' => 'bottom', + ], + 'bar' => [ + 'id' => 'bar', + 'label' => 'Bar', + 'plugin' => 'system_powered_by_block', + 'region' => 'top', + ], + 'bing' => [ + 'id' => 'bing', + 'label' => 'Bing', + 'plugin' => 'system_powered_by_block', + 'region' => 'bottom', + 'weight' => -10, + ], + 'baz' => [ + 'id' => 'baz', + 'label' => 'Baz', + 'plugin' => 'system_powered_by_block', + 'region' => 'bottom', + ], + ]; + $block_manager = $this->prophesize(BlockManagerInterface::class); + $plugins = []; + foreach ($blocks as $block_id => $block) { + $plugin = $this->prophesize(BlockPluginInterface::class); + $plugin->label()->willReturn($block['label']); + $plugin->getConfiguration()->willReturn($block); + $plugins[$block_id] = $plugin->reveal(); + + $block_manager->createInstance($block_id, $block) + ->willReturn($plugin->reveal()) + ->shouldBeCalled(); + } + + + $block_plugin_collection = new BlockPluginCollection($block_manager->reveal(), $blocks); + $expected = [ + 'bottom' => [ + 'bing' => $plugins['bing'], + 'baz' => $plugins['baz'], + 'foo' => $plugins['foo'], + ], + 'top' => [ + 'bar' => $plugins['bar'], + ], + ]; + $this->assertSame($expected, $block_plugin_collection->getAllByRegion()); + } + +}