You are here

protected function IpIsBannedTest::setUp in Rules 8.3

Overrides RulesIntegrationTestBase::setUp

File

tests/src/Unit/Integration/Condition/IpIsBannedTest.php, line 44

Class

IpIsBannedTest
@coversDefaultClass \Drupal\rules\Plugin\Condition\IpIsBanned @group RulesCondition

Namespace

Drupal\Tests\rules\Unit\Integration\Condition

Code

protected function setUp() : void {
  parent::setUp();

  // Must enable the ban module.
  $this
    ->enableModule('ban');
  $this->banManager = $this
    ->prophesize(BanIpManagerInterface::class);
  $this->container
    ->set('ban.ip_manager', $this->banManager
    ->reveal());

  // Mock a request.
  $this->request = $this
    ->prophesize(Request::class);

  // Mock the request_stack service, make it return our mocked request,
  // and register it in the container.
  $this->requestStack = $this
    ->prophesize(RequestStack::class);
  $this->requestStack
    ->getCurrentRequest()
    ->willReturn($this->request
    ->reveal());
  $this->container
    ->set('request_stack', $this->requestStack
    ->reveal());
  $this->condition = $this->conditionManager
    ->createInstance('rules_ip_is_banned');
}