Issue #2723521 by valthebald: Remove entity_load* usage for action entity type

8.2.x
Alex Pott 2016-05-11 15:47:50 -05:00
parent 267617572e
commit f0e5004171
4 changed files with 11 additions and 8 deletions

View File

@ -25,7 +25,9 @@ class ActionUninstallTest extends WebTestBase {
public function testActionUninstall() {
\Drupal::service('module_installer')->uninstall(array('action'));
$this->assertTrue(entity_load('action', 'user_block_user_action', TRUE), 'Configuration entity \'user_block_user_action\' still exists after uninstalling action module.' );
$storage = $this->container->get('entity_type.manager')->getStorage('action');
$storage->resetCache(['user_block_user_action']);
$this->assertTrue($storage->load('user_block_user_action'), 'Configuration entity \'user_block_user_action\' still exists after uninstalling action module.' );
$admin_user = $this->drupalCreateUser(array('administer users'));
$this->drupalLogin($admin_user);

View File

@ -4,6 +4,7 @@ namespace Drupal\action\Tests;
use Drupal\Component\Utility\Crypt;
use Drupal\simpletest\WebTestBase;
use Drupal\system\Entity\Action;
/**
* Tests complex actions configuration by adding, editing, and deleting a
@ -81,7 +82,7 @@ class ConfigurationTest extends WebTestBase {
$this->assertResponse(200);
$this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action.");
$action = entity_load('action', $aid);
$action = Action::load($aid);
$this->assertFalse($action, 'Make sure the action is gone after being deleted.');
}

View File

@ -29,12 +29,12 @@ class CommentActionsTest extends CommentTestBase {
$comment = $this->postComment($this->node, $comment_text, $subject);
// Unpublish a comment.
$action = entity_load('action', 'comment_unpublish_action');
$action = Action::load('comment_unpublish_action');
$action->execute(array($comment));
$this->assertTrue($comment->isPublished() === FALSE, 'Comment was unpublished');
// Publish a comment.
$action = entity_load('action', 'comment_publish_action');
$action = Action::load('comment_publish_action');
$action->execute(array($comment));
$this->assertTrue($comment->isPublished() === TRUE, 'Comment was published');
}

View File

@ -984,7 +984,7 @@ function user_user_role_insert(RoleInterface $role) {
}
$add_id = 'user_add_role_action.' . $role->id();
if (!entity_load('action', $add_id)) {
if (!Action::load($add_id)) {
$action = Action::create(array(
'id' => $add_id,
'type' => 'user',
@ -997,7 +997,7 @@ function user_user_role_insert(RoleInterface $role) {
$action->trustData()->save();
}
$remove_id = 'user_remove_role_action.' . $role->id();
if (!entity_load('action', $remove_id)) {
if (!Action::load($remove_id)) {
$action = Action::create(array(
'id' => $remove_id,
'type' => 'user',
@ -1024,10 +1024,10 @@ function user_user_role_delete(RoleInterface $role) {
return;
}
$actions = entity_load_multiple('action', array(
$actions = Action::loadMultiple([
'user_add_role_action.' . $role->id(),
'user_remove_role_action.' . $role->id(),
));
]);
foreach ($actions as $action) {
$action->delete();
}