ParagraphsTypeHasEnabledBehaviorPluginTest.php in Paragraphs 8
File
tests/src/Kernel/ParagraphsTypeHasEnabledBehaviorPluginTest.php
View source
<?php
namespace Drupal\Tests\paragraphs\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\paragraphs\Entity\ParagraphsType;
class ParagraphsTypeHasEnabledBehaviorPluginTest extends KernelTestBase {
public static $modules = [
'paragraphs',
'user',
'paragraphs_test',
'file',
];
protected $paragraphsType;
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installEntitySchema('paragraph');
\Drupal::moduleHandler()
->loadInclude('paragraphs', 'install');
$this->paragraphsType = ParagraphsType::create([
'label' => 'test_text',
'id' => 'test_text',
'behavior_plugins' => [
'test_text_color' => [
'enabled' => TRUE,
],
'test_dummy_behavior' => [
'enabled' => FALSE,
],
],
]);
$this->paragraphsType
->save();
}
public function testValidPluginIds() {
$this
->assertTrue($this->paragraphsType
->hasEnabledBehaviorPlugin('test_text_color'));
$this
->assertFalse($this->paragraphsType
->hasEnabledBehaviorPlugin('test_dummy_behavior'));
}
public function testInvalidPluginId() {
$this
->assertFalse($this->paragraphsType
->hasEnabledBehaviorPlugin('i_do_not_exist'));
}
}