adminUser = $this->drupalCreateUser($this->permissions); } /** * Creates a custom block. * * @param string $title * (optional) Title of block. When no value is given uses a random name. * Defaults to FALSE. * @param string $bundle * (optional) Bundle name. Defaults to 'basic'. * * @return \Drupal\custom_block\Entity\CustomBlock * Created custom block. */ protected function createCustomBlock($title = FALSE, $bundle = 'basic') { $title = ($title ? : $this->randomName()); if ($custom_block = entity_create('custom_block', array( 'info' => $title, 'type' => $bundle, 'langcode' => 'en' ))) { $custom_block->save(); } return $custom_block; } /** * Creates a custom block type (bundle). * * @param string $label * The block type label. * * @return \Drupal\custom_block\Entity\CustomBlockType * Created custom block type. */ protected function createCustomBlockType($label) { $bundle = entity_create('custom_block_type', array( 'id' => $label, 'label' => $label, 'revision' => FALSE )); $bundle->save(); return $bundle; } }