only in patch2: unchanged: --- /dev/null +++ b/core/modules/block_content/src/Tests/BlockContentValidationTest.php @@ -0,0 +1,45 @@ +randomMachineName(); + $block = $this->createBlockContent($description, 'basic', FALSE); + // Validate the block. + $violations = $block->validate(); + // Make sure we have no violations. + $this->assertEqual(count($violations), 0); + // Save the block. + $block->save(); + + // Add another block with the same description. + $block = $this->createBlockContent($description, 'basic', FALSE); + // Validate this block. + $violations = $block->validate(); + // Make sure we have 1 violation. + $this->assertEqual(count($violations), 1); + // Make sure the violation is on the info property + $this->assertEqual($violations[0]->getPropertyPath(), 'info'); + // Make sure the message is correct. + $this->assertEqual($violations[0]->getMessage(), format_string('A block with description %value already exists.', [ + '%value' => $block->label(), + ])); + } + +}