You are here

public function UserBlockTest::testBlockUserWithValidUser in Rules 8.3

Test execute() method for active and authenticated users.

@covers ::execute

File

tests/src/Unit/Integration/RulesAction/UserBlockTest.php, line 75

Class

UserBlockTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\UserBlock @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testBlockUserWithValidUser() {
  $user = $this
    ->getUserMock(self::ACTIVE, self::AUTHENTICATED);
  $user
    ->block()
    ->shouldBeCalledTimes(1);
  $user
    ->id()
    ->willReturn('123')
    ->shouldBeCalledTimes(1);
  $this->sessionManager
    ->delete('123')
    ->shouldBeCalledTimes(1);
  $this->action
    ->setContextValue('user', $user
    ->reveal());
  $this->action
    ->execute();
  $this
    ->assertEquals($this->action
    ->autoSaveContext(), [
    'user',
  ], 'Action returns the user context name for auto saving.');
}