3 namespace Drupal\Tests\block_content\Functional;
6 * Tests block content validation constraints.
10 class BlockContentValidationTest extends BlockContentTestBase {
13 * Tests the block content validation constraints.
15 public function testValidation() {
17 $description = $this->randomMachineName();
18 $block = $this->createBlockContent($description, 'basic');
19 // Validate the block.
20 $violations = $block->validate();
21 // Make sure we have no violations.
22 $this->assertEqual(count($violations), 0);
26 // Add another block with the same description.
27 $block = $this->createBlockContent($description, 'basic');
28 // Validate this block.
29 $violations = $block->validate();
30 // Make sure we have 1 violation.
31 $this->assertEqual(count($violations), 1);
32 // Make sure the violation is on the info property
33 $this->assertEqual($violations[0]->getPropertyPath(), 'info');
34 // Make sure the message is correct.
35 $this->assertEqual($violations[0]->getMessage(), format_string('A custom block with block description %value already exists.', [
36 '%value' => $block->label(),