public function AdvbanMiddlewareTest::testBannedIp in Advanced ban 8
Tests a banned IP.
File
- tests/
src/ Unit/ AdvbanMiddlewareTest.php, line 52
Class
- AdvbanMiddlewareTest
- @coversDefaultClass \Drupal\advban\AdvbanMiddleware @group Advban
Namespace
Drupal\Tests\advban\UnitCode
public function testBannedIp() {
$banned_ip = '17.0.0.2';
$this->banManager
->expects($this
->once())
->method('isBanned')
->with($banned_ip)
->willReturn([
'is_banned' => TRUE,
'expiry_date' => 0,
]);
$request = Request::create('/test-path');
$request->server
->set('REMOTE_ADDR', $banned_ip);
$response = $this->banMiddleware
->handle($request);
$this
->assertEquals(403, $response
->getStatusCode());
}