diff --git a/core/modules/block_content/src/Tests/BlockContentTestBase.php b/core/modules/block_content/src/Tests/BlockContentTestBase.php index a7c401d..92fc30d 100644 --- a/core/modules/block_content/src/Tests/BlockContentTestBase.php +++ b/core/modules/block_content/src/Tests/BlockContentTestBase.php @@ -91,27 +91,23 @@ protected function createBlockContent($title = FALSE, $bundle = 'basic') { * * @param string $label * The block type label. + * @param bool $create_body + * Whether or not to create the body field * * @return \Drupal\block_content\Entity\BlockContentType * Created custom block type. */ - protected function createBlockContentType($label) { + protected function createBlockContentType($label, $create_body = FALSE) { $bundle = entity_create('block_content_type', array( 'id' => $label, 'label' => $label, - 'revision' => FALSE + 'revision' => FALSE, )); $bundle->save(); + if ($create_body) { + block_content_add_body_field($bundle->id()); + } return $bundle; } - /** - * Creates the basic block-type. - */ - protected function createBasicBlockType() { - // Ensure the basic bundle exists. - $block_content_type = $this->createBlockContentType('basic'); - block_content_add_body_field($block_content_type->id()); - } - } diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index b3cec58..f0ef894 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -7,6 +7,7 @@ namespace Drupal\block_content\Tests; use Drupal\Component\Utility\Html; +use Drupal\Core\Url; /** * Ensures that custom block type functions work correctly. @@ -49,9 +50,11 @@ public function testBlockContentTypeCreation() { // Test the page with no block-types. $this->drupalGet('block/add'); $this->assertResponse(200); - $this->assertText('You have not created any block types yet'); + $this->assertRaw(t('You have not created any block types yet. Go to the block type creation page to add a new block type.', [ + '!url' => Url::fromRoute('block_content.type_add')->toString(), + ])); // Now create an initial block-type. - $this->createBasicBlockType(); + $this->createBlockContentType('basic', TRUE); // Create a block type programmaticaly. $type = $this->createBlockContentType('other'); @@ -83,7 +86,7 @@ public function testBlockContentTypeCreation() { */ public function testBlockContentTypeEditing() { // Now create an initial block-type. - $this->createBasicBlockType(); + $this->createBlockContentType('basic', TRUE); $this->drupalLogin($this->adminUser); // We need two block types to prevent /block/add redirecting. @@ -123,7 +126,7 @@ public function testBlockContentTypeEditing() { */ public function testBlockContentTypeDeletion() { // Now create an initial block-type. - $this->createBasicBlockType(); + $this->createBlockContentType('basic', TRUE); // Create a block type programmatically. $type = $this->createBlockContentType('foo'); @@ -156,7 +159,7 @@ public function testBlockContentTypeDeletion() { */ public function testsBlockContentAddTypes() { // Now create an initial block-type. - $this->createBasicBlockType(); + $this->createBlockContentType('basic', TRUE); $this->drupalLogin($this->adminUser); // Create two block types programmatically.