Commit 252fee22 authored by catch's avatar catch

Issue #2503409 by dimaro, DuaelFr, lluvigne: Replace deprecated usage of...

Issue #2503409 by dimaro, DuaelFr, lluvigne: Replace deprecated usage of entity_create('block*') with a direct call to Block::create()
parent b04e99ad
......@@ -7,6 +7,7 @@
namespace Drupal\block\Tests;
use Drupal\block\Entity\Block;
use Drupal\simpletest\WebTestBase;
/**
......@@ -31,8 +32,7 @@ function testBlockThemeHookSuggestions() {
// an underscore (not transformed) and a hyphen (transformed to underscore),
// and generates possibilities for each level of derivative.
// @todo Clarify this comment.
/** @var \Drupal\block\BlockInterface $block */
$block = entity_create('block', array(
$block = Block::create(array(
'plugin' => 'system_menu_block:admin',
'region' => 'footer',
'id' => 'machinename',
......
......@@ -7,6 +7,8 @@
namespace Drupal\block_content\Tests;
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\LanguageInterface;
......@@ -29,7 +31,7 @@ class BlockContentCacheTagsTest extends EntityCacheTagsTestBase {
* {@inheritdoc}
*/
protected function createEntity() {
$block_content_type = entity_create('block_content_type', array(
$block_content_type = BlockContentType::create(array(
'id' => 'basic',
'label' => 'basic',
'revision' => FALSE
......@@ -38,7 +40,7 @@ protected function createEntity() {
block_content_add_body_field($block_content_type->id());
// Create a "Llama" custom block.
$block_content = entity_create('block_content', array(
$block_content = BlockContent::create(array(
'info' => 'Llama',
'type' => 'basic',
'body' => array(
......
......@@ -46,7 +46,7 @@ public function testImport() {
'type' => 'basic',
'id' => $test_id
);
$block = entity_create('block_content', $block_array);
$block = BlockContent::create($block_array);
$block->enforceIsNew(TRUE);
$block->save();
......
......@@ -7,6 +7,8 @@
namespace Drupal\block_content\Tests;
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\simpletest\WebTestBase;
/**
......@@ -78,7 +80,7 @@ protected function setUp() {
*/
protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) {
$title = ($title ? : $this->randomMachineName());
$block_content = entity_create('block_content', array(
$block_content = BlockContent::create(array(
'info' => $title,
'type' => $bundle,
'langcode' => 'en'
......@@ -101,7 +103,7 @@ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save =
* Created custom block type.
*/
protected function createBlockContentType($label, $create_body = FALSE) {
$bundle = entity_create('block_content_type', array(
$bundle = BlockContentType::create(array(
'id' => $label,
'label' => $label,
'revision' => FALSE,
......
......@@ -7,6 +7,8 @@
namespace Drupal\block_content\Tests;
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Component\Utility\Unicode;
use Drupal\content_translation\Tests\ContentTranslationUITestBase;
......@@ -60,7 +62,7 @@ protected function setUp() {
*/
protected function setupBundle() {
// Create the basic bundle since it is provided by standard.
$bundle = entity_create('block_content_type', array(
$bundle = BlockContentType::create(array(
'id' => $this->bundle,
'label' => $this->bundle,
'revision' => FALSE
......@@ -96,7 +98,7 @@ public function getTranslatorPermissions() {
protected function createBlockContent($title = FALSE, $bundle = FALSE) {
$title = ($title ? : $this->randomMachineName());
$bundle = ($bundle ? : $this->bundle);
$block_content = entity_create('block_content', array(
$block_content = BlockContent::create(array(
'info' => $title,
'type' => $bundle,
'langcode' => 'en'
......@@ -162,7 +164,7 @@ protected function doTestBasicTranslation() {
public function testDisabledBundle() {
// Create a bundle that does not have translation enabled.
$disabled_bundle = $this->randomMachineName();
$bundle = entity_create('block_content_type', array(
$bundle = BlockContentType::create(array(
'id' => $disabled_bundle,
'label' => $disabled_bundle,
'revision' => FALSE
......
......@@ -7,6 +7,7 @@
namespace Drupal\block_content\Tests\Views;
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\views\Tests\ViewTestBase;
......@@ -69,7 +70,7 @@ protected function createBlockContent(array $settings = array()) {
'type' => 'basic',
'langcode' => 'en',
);
if ($block_content = entity_create('block_content', $settings)) {
if ($block_content = BlockContent::create($settings)) {
$status = $block_content->save();
}
$this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content %info.', array('%info' => $block_content->label())));
......@@ -100,7 +101,7 @@ protected function createBlockContentType(array $values = array()) {
'label' => $id,
'revision' => FALSE
);
$bundle = entity_create('block_content_type', $values);
$bundle = BlockContentType::create($values);
$status = $bundle->save();
block_content_add_body_field($bundle->id());
......
......@@ -7,6 +7,7 @@
namespace Drupal\config_translation\Tests;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Component\Utility\Unicode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
......@@ -189,7 +190,7 @@ protected function doVocabularyListTest() {
public function doCustomContentTypeListTest() {
// Create a test custom block type to decouple looking for translate
// operations link so this does not test more than necessary.
$block_content_type = entity_create('block_content_type', array(
$block_content_type = BlockContentType::create(array(
'id' => Unicode::strtolower($this->randomMachineName(16)),
'label' => $this->randomMachineName(),
'revision' => FALSE
......@@ -395,7 +396,7 @@ public function doFieldListTest() {
));
// Create a block content type.
$block_content_type = entity_create('block_content_type', array(
$block_content_type = BlockContentType::create(array(
'id' => 'basic',
'label' => 'Basic',
'revision' => FALSE
......
......@@ -7,7 +7,7 @@
namespace Drupal\system\Tests\Block;
use Drupal\system\Entity\Menu;
use Drupal\block\Entity\Block;
use Drupal\Core\Render\Element;
use Drupal\simpletest\KernelTestBase;
use Drupal\system\Tests\Routing\MockRouteProvider;
......@@ -157,7 +157,7 @@ protected function setUp() {
*/
public function testSystemMenuBlockConfigDependencies() {
$block = entity_create('block', array(
$block = Block::create(array(
'plugin' => 'system_menu_block:' . $this->menu->id(),
'region' => 'footer',
'id' => 'machinename',
......
......@@ -87,7 +87,7 @@ protected function assertHookMessageOrder($messages) {
* Tests hook invocations for CRUD operations on blocks.
*/
public function testBlockHooks() {
$entity = entity_create('block', array(
$entity = Block::create(array(
'id' => 'stark_test_html',
'plugin' => 'test_html',
'theme' => 'stark',
......
......@@ -8,6 +8,7 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Tests\ViewKernelTestBase;
use Drupal\block\Entity\Block;
/**
* Tests views block config dependencies functionality.
......@@ -106,7 +107,7 @@ protected function createBlock($plugin_id, array $settings = array()) {
$values['visibility'][$id]['id'] = $id;
}
$values['settings'] = $settings;
$block = entity_create('block', $values);
$block = Block::create($values);
$block->save();
return $block;
}
......
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