You are here

EntityDeleteTest.php in Rules 8.3

File

tests/src/Unit/Integration/RulesAction/EntityDeleteTest.php
View source
<?php

namespace Drupal\Tests\rules\Unit\Integration\RulesAction;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Tests\rules\Unit\Integration\RulesEntityIntegrationTestBase;

/**
 * @coversDefaultClass \Drupal\rules\Plugin\RulesAction\EntityDelete
 * @group RulesAction
 */
class EntityDeleteTest extends RulesEntityIntegrationTestBase {

  /**
   * The action to be tested.
   *
   * @var \Drupal\rules\Core\RulesActionInterface
   */
  protected $action;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->action = $this->actionManager
      ->createInstance('rules_entity_delete');
  }

  /**
   * Tests the summary.
   *
   * @covers ::summary
   */
  public function testSummary() {
    $this
      ->assertEquals('Delete entity', $this->action
      ->summary());
  }

  /**
   * Tests the action execution.
   *
   * @covers ::execute
   */
  public function testActionExecution() {
    $entity = $this
      ->prophesizeEntity(EntityInterface::class);
    $entity
      ->delete()
      ->shouldBeCalledTimes(1);
    $this->action
      ->setContextValue('entity', $entity
      ->reveal());
    $this->action
      ->execute();
  }

}

Classes

Namesort descending Description
EntityDeleteTest @coversDefaultClass \Drupal\rules\Plugin\RulesAction\EntityDelete @group RulesAction