X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fctools%2Ftests%2Fsrc%2FUnit%2FBlockVariantTraitTest.php;fp=web%2Fmodules%2Fcontrib%2Fctools%2Ftests%2Fsrc%2FUnit%2FBlockVariantTraitTest.php;h=8926879435426f7674e703c95f16456b76756043;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/ctools/tests/src/Unit/BlockVariantTraitTest.php b/web/modules/contrib/ctools/tests/src/Unit/BlockVariantTraitTest.php new file mode 100644 index 000000000..892687943 --- /dev/null +++ b/web/modules/contrib/ctools/tests/src/Unit/BlockVariantTraitTest.php @@ -0,0 +1,149 @@ +prophesize(BlockPluginCollection::class); + $block_collection->getAllByRegion() + ->willReturn($blocks) + ->shouldBeCalled(); + + $display_variant = new TestBlockVariantTrait(); + $display_variant->setBlockPluginCollection($block_collection->reveal()); + + $this->assertSame($expected, $display_variant->getRegionAssignments()); + } + + public function providerTestGetRegionAssignments() { + return [ + [ + [ + 'top' => [], + 'bottom' => [], + ], + ], + [ + [ + 'top' => ['foo'], + 'bottom' => [], + ], + [ + 'top' => ['foo'], + ], + ], + [ + [ + 'top' => [], + 'bottom' => [], + ], + [ + 'invalid' => ['foo'], + ], + ], + [ + [ + 'top' => [], + 'bottom' => ['foo'], + ], + [ + 'bottom' => ['foo'], + 'invalid' => ['bar'], + ], + ], + ]; + } + +} + +class TestBlockVariantTrait { + use BlockVariantTrait; + + /** + * @var array + */ + protected $blockConfig = []; + + /** + * @var \Drupal\Component\Uuid\UuidInterface + */ + protected $uuidGenerator; + + /** + * @param BlockPluginCollection $block_plugin_collection + * + * @return $this + */ + public function setBlockPluginCollection(BlockPluginCollection $block_plugin_collection) { + $this->blockPluginCollection = $block_plugin_collection; + return $this; + } + + /** + * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator + * + * @return $this + */ + public function setUuidGenerator(UuidInterface $uuid_generator) { + $this->uuidGenerator = $uuid_generator; + return $this; + } + + /** + * {@inheritdoc} + */ + protected function uuidGenerator() { + return $this->uuidGenerator; + } + + /** + * Sets the block configuration. + * + * @param array $config + * The block configuration. + * + * @return $this + */ + public function setBlockConfig(array $config) { + $this->blockConfig = $config; + return $this; + } + + /** + * {@inheritdoc} + */ + protected function getBlockConfig() { + return $this->blockConfig; + } + + /** + * {@inheritdoc} + */ + public function getRegionNames() { + return [ + 'top' => 'Top', + 'bottom' => 'Bottom', + ]; + } + +}