Issue #2568027 by alexpott, dawehner: Improve BlockContentTypeTest

8.0.x
xjm 2015-09-14 12:45:23 -05:00
parent 7dee9f8f27
commit db5cf5439b
1 changed files with 19 additions and 15 deletions

View File

@ -52,35 +52,39 @@ class BlockContentTypeTest extends BlockContentTestBase {
// 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);
}
/**