X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fblock_content%2Ftests%2Fsrc%2FKernel%2FBlockContentDeriverTest.php;fp=web%2Fcore%2Fmodules%2Fblock_content%2Ftests%2Fsrc%2FKernel%2FBlockContentDeriverTest.php;h=d08d86f25fa8a86f23bbbafd0733d33bd75c0e24;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php b/web/core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php new file mode 100644 index 000000000..d08d86f25 --- /dev/null +++ b/web/core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php @@ -0,0 +1,66 @@ +installSchema('system', ['sequence']); + $this->installEntitySchema('user'); + $this->installEntitySchema('block_content'); + } + + /** + * Tests that only reusable blocks are derived. + */ + public function testReusableBlocksOnlyAreDerived() { + // Create a block content type. + $block_content_type = BlockContentType::create([ + 'id' => 'spiffy', + 'label' => 'Mucho spiffy', + 'description' => "Provides a block type that increases your site's spiffiness by up to 11%", + ]); + $block_content_type->save(); + // And a block content entity. + $block_content = BlockContent::create([ + 'info' => 'Spiffy prototype', + 'type' => 'spiffy', + ]); + $block_content->save(); + + // Ensure the reusable block content is provided as a derivative block + // plugin. + /** @var \Drupal\Core\Block\BlockManagerInterface $block_manager */ + $block_manager = $this->container->get('plugin.manager.block'); + $plugin_id = 'block_content' . PluginBase::DERIVATIVE_SEPARATOR . $block_content->uuid(); + $this->assertTrue($block_manager->hasDefinition($plugin_id)); + + // Set the block not to be reusable. + $block_content->setNonReusable(); + $block_content->save(); + + // Ensure the non-reusable block content is not provided a derivative block + // plugin. + $this->assertFalse($block_manager->hasDefinition($plugin_id)); + } + +}