function UnBanIpTest::testActionExecutionWithContextIpv4

Tests the action execution with Context IPv4.

Uses the 192.0.2.0/24 "TEST-NET" address block as defined in RFC3330.

@covers ::execute

See also

http://en.wikipedia.org/wiki/Reserved_IP_addresses

https://tools.ietf.org/html/rfc3330

File

tests/src/Unit/Integration/RulesAction/UnBanIpTest.php, line 94

Class

UnBanIpTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\UnBanIp @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

public function testActionExecutionWithContextIpv4() {
    // TEST-NET-1 IPv4.
    $ipv4 = '192.0.2.0';
    $this->action
        ->setContextValue('ip', $ipv4);
    $this->banManager
        ->unbanIp($ipv4)
        ->shouldBeCalledTimes(1);
    $this->action
        ->execute();
    $this->logger
        ->notice('Removed ban on IP address %ip', [
        '%ip' => $ipv4,
    ])
        ->shouldHaveBeenCalled();
}