Issue #2099417 by marthinal, swentel, lauriii: Fixed Unable to change Custom Block view mode.
parent
2280ad5dec
commit
9b5afa85e3
|
@ -113,6 +113,7 @@ class CustomBlockBlock extends BlockBase implements ContainerFactoryPluginInterf
|
|||
public function blockSubmit($form, &$form_state) {
|
||||
// Invalidate the block cache to update custom block-based derivatives.
|
||||
if ($this->moduleHandler->moduleExists('block')) {
|
||||
$this->configuration['view_mode'] = $form_state['values']['custom_block']['view_mode'];
|
||||
$this->blockManager->clearCachedDefinitions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,21 @@ class CustomBlockCreationTest extends CustomBlockTestBase {
|
|||
* Creates a "Basic page" block and verifies its consistency in the database.
|
||||
*/
|
||||
public function testCustomBlockCreation() {
|
||||
// Add a new view mode and verify if it is selected as expected.
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer display modes')));
|
||||
$this->drupalGet('admin/structure/display-modes/view/add/custom_block');
|
||||
$edit = array(
|
||||
'id' => 'test_view_mode',
|
||||
'label' => 'Test View Mode',
|
||||
);
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
$this->assertRaw(t('Saved the %label view mode.', array('%label' => $edit['label'])));
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Create a block.
|
||||
$edit = array();
|
||||
$edit['info'] = $this->randomName(8);
|
||||
$edit['info'] = 'Test Block';
|
||||
$edit['body[0][value]'] = $this->randomName(16);
|
||||
$this->drupalPostForm('block/add/basic', $edit, t('Save'));
|
||||
|
||||
|
@ -58,6 +70,14 @@ class CustomBlockCreationTest extends CustomBlockTestBase {
|
|||
'%name' => $edit["info"]
|
||||
)), 'Basic block created.');
|
||||
|
||||
// Change the view mode.
|
||||
$view_mode['settings[custom_block][view_mode]'] = 'test_view_mode';
|
||||
$this->drupalPostForm(NULL, $view_mode, t('Save block'));
|
||||
|
||||
// Go to the configure page and verify that the new view mode is correct.
|
||||
$this->drupalGet('admin/structure/block/manage/testblock');
|
||||
$this->assertFieldByXPath('//select[@name="settings[custom_block][view_mode]"]/option[@selected="selected"]/@value', 'test_view_mode', 'View mode changed to Test View Mode');
|
||||
|
||||
// Check that the block exists in the database.
|
||||
$blocks = entity_load_multiple_by_properties('custom_block', array('info' => $edit['info']));
|
||||
$block = reset($blocks);
|
||||
|
|
Loading…
Reference in New Issue