class BlockContentDeriverTest
Same name and namespace in other branches
- 11.x core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php \Drupal\Tests\block_content\Kernel\BlockContentDeriverTest
- 10 core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php \Drupal\Tests\block_content\Kernel\BlockContentDeriverTest
- 8.9.x core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php \Drupal\Tests\block_content\Kernel\BlockContentDeriverTest
Tests block content plugin deriver.
@group block_content
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\block_content\Kernel\BlockContentDeriverTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of BlockContentDeriverTest
File
-
core/
modules/ block_content/ tests/ src/ Kernel/ BlockContentDeriverTest.php, line 15
Namespace
Drupal\Tests\block_content\KernelView source
class BlockContentDeriverTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
'block_content',
'system',
'user',
];
/**
* {@inheritdoc}
*/
public function setUp() : void {
parent::setUp();
$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));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.