You are here

public function BanIpTest::testActionExecutionWithoutContextIp in Rules 8.3

Tests the action execution without Context IP set.

Should fallback to the current IP of the request.

@covers ::execute

File

tests/src/Unit/Integration/RulesAction/BanIpTest.php, line 135

Class

BanIpTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\BanIp @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testActionExecutionWithoutContextIp() {

  // TEST-NET-1 IPv4.
  $ip = '192.0.2.0';
  $this->request
    ->getClientIp()
    ->willReturn($ip)
    ->shouldBeCalledTimes(1);
  $this->banManager
    ->banIp($ip)
    ->shouldBeCalledTimes(1);
  $this->action
    ->execute();
  $this->logger
    ->notice('Banned IP address %ip', [
    '%ip' => $ip,
  ])
    ->shouldHaveBeenCalled();
}