UserIsBlockedTest.php in Rules 8.3
File
tests/src/Unit/Integration/Condition/UserIsBlockedTest.php
View source
<?php
namespace Drupal\Tests\rules\Unit\Integration\Condition;
use Drupal\Tests\rules\Unit\Integration\RulesEntityIntegrationTestBase;
use Drupal\user\UserInterface;
class UserIsBlockedTest extends RulesEntityIntegrationTestBase {
protected $condition;
protected function setUp() : void {
parent::setUp();
$this
->enableModule('user');
$this->condition = $this->conditionManager
->createInstance('rules_user_is_blocked');
}
public function testConditionEvaluation() {
$blocked_user = $this
->prophesizeEntity(UserInterface::class);
$blocked_user
->isBlocked()
->willReturn(TRUE)
->shouldbeCalledTimes(1);
$this->condition
->setContextValue('user', $blocked_user
->reveal());
$this
->assertTrue($this->condition
->evaluate());
$active_user = $this
->prophesizeEntity(UserInterface::class);
$active_user
->isBlocked()
->willReturn(FALSE)
->shouldbeCalledTimes(1);
$this->condition
->setContextValue('user', $active_user
->reveal());
$this
->assertFalse($this->condition
->evaluate());
}
}