Commit db5cf543 authored by xjm's avatar xjm

Issue #2568027 by alexpott, dawehner: Improve BlockContentTypeTest

parent 7dee9f8f
......@@ -52,35 +52,39 @@ public function testBlockContentTypeCreation() {
// Test the page with no block-types.
$this->drupalGet('block/add');
$this->assertResponse(200);
$this->assertRaw(t('You have not created any block types yet. Go to the <a href="!url">block type creation page</a> to add a new block type.', [
'!url' => Url::fromRoute('block_content.type_add')->toString(),
]));
// Now create an initial block-type.
$this->createBlockContentType('basic', TRUE);
// Create a block type programmatically.
$type = $this->createBlockContentType('other');
$block_type = BlockContentType::load('other');
$this->assertTrue($block_type, 'The new block type has been created.');
$this->drupalGet('block/add/' . $type->id());
$this->assertResponse(200, 'The new block type can be accessed at block/add.');
$this->assertText('You have not created any block types yet');
$this->clickLink('block type creation page');
// Create a block type via the user interface.
$edit = array(
'id' => 'foo',
'label' => 'title for foo',
);
$this->drupalPostForm('admin/structure/block/block-content/types/add', $edit, t('Save'));
$this->drupalPostForm(NULL, $edit, t('Save'));
$block_type = BlockContentType::load('foo');
$this->assertTrue($block_type, 'The new block type has been created.');
$field_definitions = \Drupal::entityManager()->getFieldDefinitions('block_content', 'foo');
$this->assertTrue(isset($field_definitions['body']), 'Body field was created when using the UI to create block content types.');
$this->assertTrue(isset($field_definitions['body']), 'Body field created when using the UI to create block content types.');
// Check that the block type was created in site default language.
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
$this->assertEqual($block_type->language()->getId(), $default_langcode);
// Create block types programmatically.
$this->createBlockContentType('basic', TRUE);
$field_definitions = \Drupal::entityManager()->getFieldDefinitions('block_content', 'basic');
$this->assertTrue(isset($field_definitions['body']), "Body field for 'basic' block type created when using the testing API to create block content types.");
$this->createBlockContentType('other');
$field_definitions = \Drupal::entityManager()->getFieldDefinitions('block_content', 'other');
$this->assertFalse(isset($field_definitions['body']), "Body field for 'other' block type not created when using the testing API to create block content types.");
$block_type = BlockContentType::load('other');
$this->assertTrue($block_type, 'The new block type has been created.');
$this->drupalGet('block/add/' . $block_type->id());
$this->assertResponse(200);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment