Commit a3fea498 authored by alexpott's avatar alexpott

Issue #2025325 by naxoc, pplantinga, jessebeach: Fixed Add custom block action...

Issue #2025325 by naxoc, pplantinga, jessebeach: Fixed Add custom block action results in a fatal error.
parent 3506077c
......@@ -68,16 +68,19 @@ public function __construct(PluginManagerInterface $entity_manager, EntityStorag
/**
* Displays add custom block links for available types.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request object.
*
* @return array
* A render array for a list of the custom block types that can be added or
* if there is only one custom block type defined for the site, the function
* returns the custom block add page for that custom block type.
*/
public function add() {
public function add(Request $request) {
$types = $this->customBlockTypeStorage->load();
if ($types && count($types) == 1) {
$type = reset($types);
return $this->addForm($type);
return $this->addForm($type, $request);
}
return array('#theme' => 'custom_block_add_list', '#content' => $types);
......
......@@ -66,6 +66,32 @@ public function testCustomBlockCreation() {
$this->assertTrue($block, 'Custom Block found in database.');
}
/**
* Create a default custom block.
*
* Creates a custom block from defaults and ensures that the 'basic block'
* type is being used.
*/
public function testDefaultCustomBlockCreation() {
$edit = array();
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit['info'] = $this->randomName(8);
$edit["block_body[$langcode][0][value]"] = $this->randomName(16);
// Don't pass the custom block type in the url so the default is forced.
$this->drupalPost('block/add', $edit, t('Save'));
// Check that the block has been created and that it is a basic block.
$this->assertRaw(format_string('!block %name has been created.', array(
'!block' => 'Basic block',
'%name' => $edit["info"],
)), 'Basic block created.');
// Check that the block exists in the database.
$blocks = entity_load_multiple_by_properties('custom_block', array('info' => $edit['info']));
$block = reset($blocks);
$this->assertTrue($block, 'Default Custom Block found in database.');
}
/**
* Verifies that a transaction rolls back the failed creation.
*/
......
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