Namespace
Drupal\Tests\rules\Unit\Integration\RulesAction
File
-
tests/src/Unit/Integration/RulesAction/UserUnblockTest.php
View source
<?php
namespace Drupal\Tests\rules\Unit\Integration\RulesAction;
use Drupal\Tests\rules\Unit\Integration\RulesEntityIntegrationTestBase;
use Drupal\user\UserInterface;
class UserUnblockTest extends RulesEntityIntegrationTestBase {
const AUTHENTICATED = TRUE;
const ANONYMOUS = FALSE;
const ACTIVE = TRUE;
const BLOCKED = FALSE;
protected $action;
protected function setUp() : void {
parent::setUp();
$this->enableModule('user');
$this->action = $this->actionManager
->createInstance('rules_user_unblock');
}
public function testSummary() {
$this->assertEquals('Unblock a user', $this->action
->summary());
}
public function testUnblockUser($active, $authenticated, $expects, $autosave_names) {
$account = $this->prophesizeEntity(UserInterface::class);
$account->isBlocked()
->willReturn(!$active);
$account->isAuthenticated()
->willReturn($authenticated);
$account->activate()
->shouldBeCalledTimes($expects);
$account->save()
->shouldNotBeCalled();
$this->action
->setContextValue('user', $account->reveal())
->execute();
$this->assertEquals($this->action
->autoSaveContext(), $autosave_names, 'Action returns correct context name for auto saving.');
}
public function userProvider() {
return [
[
self::BLOCKED,
self::AUTHENTICATED,
1,
[
'user',
],
],
[
self::ACTIVE,
self::ANONYMOUS,
0,
[],
],
[
self::ACTIVE,
self::AUTHENTICATED,
0,
[],
],
[
self::BLOCKED,
self::ANONYMOUS,
0,
[],
],
];
}
}
Classes
| Title |
Deprecated |
Summary |
| UserUnblockTest |
|
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\UserUnblock[[api-linebreak]]
@group RulesAction |