function BanAdminTest::getRequestStackMock

Same name in other branches
  1. 11.x core/modules/ban/tests/src/Unit/BanAdminTest.php \Drupal\Tests\ban\Unit\BanAdminTest::getRequestStackMock()

Get a request stack with a dummy IP.

1 call to BanAdminTest::getRequestStackMock()
BanAdminTest::testIpValidation in core/modules/ban/tests/src/Unit/BanAdminTest.php
Tests various user input to confirm correct validation.

File

core/modules/ban/tests/src/Unit/BanAdminTest.php, line 119

Class

BanAdminTest
Tests the BanAdmin form.

Namespace

Drupal\Tests\ban\Unit

Code

protected function getRequestStackMock() : RequestStack {
    $request = $this->createMock(Request::class);
    $request->expects($this->any())
        ->method('getClientIp')
        ->willReturn('127.0.0.1');
    $requestStack = $this->createMock(RequestStack::class);
    $requestStack->expects($this->any())
        ->method('getCurrentRequest')
        ->willReturn($request);
    return $requestStack;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.