summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-02-18 02:24:17 (GMT)
committerNathaniel Catchpole2016-02-18 02:24:17 (GMT)
commit252fee22072de3b1f9eb7b7d79c4003ef80d98b8 (patch)
treef246896fbe6f447314bb21f408430db29307dc27
parentb04e99ad2bca3b5fa54e686f2d6ef8ff1db0e828 (diff)
Issue #2503409 by dimaro, DuaelFr, lluvigne: Replace deprecated usage of entity_create('block*') with a direct call to Block::create()
-rw-r--r--core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php4
-rw-r--r--core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php6
-rw-r--r--core/modules/block_content/src/Tests/BlockContentSaveTest.php2
-rw-r--r--core/modules/block_content/src/Tests/BlockContentTestBase.php6
-rw-r--r--core/modules/block_content/src/Tests/BlockContentTranslationUITest.php8
-rw-r--r--core/modules/block_content/src/Tests/Views/BlockContentTestBase.php5
-rw-r--r--core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php5
-rw-r--r--core/modules/system/src/Tests/Block/SystemMenuBlockTest.php4
-rw-r--r--core/modules/system/src/Tests/Entity/EntityCrudHookTest.php2
-rw-r--r--core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php3
10 files changed, 27 insertions, 18 deletions
diff --git a/core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php b/core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php
index 4b2ed69..3c61d84 100644
--- a/core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php
+++ b/core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\block\Tests;
+use Drupal\block\Entity\Block;
use Drupal\simpletest\WebTestBase;
/**
@@ -31,8 +32,7 @@ class BlockTemplateSuggestionsTest extends WebTestBase {
// 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',
diff --git a/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php b/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php
index 8f543c3..567d5e1 100644
--- a/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php
@@ -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 @@ class BlockContentCacheTagsTest extends EntityCacheTagsTestBase {
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(
diff --git a/core/modules/block_content/src/Tests/BlockContentSaveTest.php b/core/modules/block_content/src/Tests/BlockContentSaveTest.php
index 75c2801..894099f 100644
--- a/core/modules/block_content/src/Tests/BlockContentSaveTest.php
+++ b/core/modules/block_content/src/Tests/BlockContentSaveTest.php
@@ -46,7 +46,7 @@ class BlockContentSaveTest extends BlockContentTestBase {
'type' => 'basic',
'id' => $test_id
);
- $block = entity_create('block_content', $block_array);
+ $block = BlockContent::create($block_array);
$block->enforceIsNew(TRUE);
$block->save();
diff --git a/core/modules/block_content/src/Tests/BlockContentTestBase.php b/core/modules/block_content/src/Tests/BlockContentTestBase.php
index ceb5846..cc6e3ad 100644
--- a/core/modules/block_content/src/Tests/BlockContentTestBase.php
+++ b/core/modules/block_content/src/Tests/BlockContentTestBase.php
@@ -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 @@ abstract class BlockContentTestBase extends WebTestBase {
*/
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 @@ abstract class BlockContentTestBase extends WebTestBase {
* 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,
diff --git a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php
index 4e4fd6b..c32fb45 100644
--- a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php
+++ b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php
@@ -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 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
*/
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 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
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 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
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
diff --git a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
index 4d65dcf..fdbec95 100644
--- a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
+++ b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
@@ -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 @@ abstract class BlockContentTestBase extends ViewTestBase {
'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 @@ abstract class BlockContentTestBase extends ViewTestBase {
'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());
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php
index 352ce81..9671feb 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php
+++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php
@@ -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 @@ class ConfigTranslationListUiTest extends WebTestBase {
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 @@ class ConfigTranslationListUiTest extends WebTestBase {
));
// 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
diff --git a/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php b/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php
index 4e6db75..6b1a81f 100644
--- a/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php
+++ b/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php
@@ -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 @@ class SystemMenuBlockTest extends KernelTestBase {
*/
public function testSystemMenuBlockConfigDependencies() {
- $block = entity_create('block', array(
+ $block = Block::create(array(
'plugin' => 'system_menu_block:' . $this->menu->id(),
'region' => 'footer',
'id' => 'machinename',
diff --git a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
index 46ddaad..8e401cd 100644
--- a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
@@ -87,7 +87,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
* 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',
diff --git a/core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php b/core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php
index 6a5064c..15863a7 100644
--- a/core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php
+++ b/core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php
@@ -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 @@ class BlockDependenciesTest extends ViewKernelTestBase {
$values['visibility'][$id]['id'] = $id;
}
$values['settings'] = $settings;
- $block = entity_create('block', $values);
+ $block = Block::create($values);
$block->save();
return $block;
}