You are here

public function CommandLineOrUnsafeMethodTest::testHttpMethod in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php \Drupal\Tests\Core\PageCache\CommandLineOrUnsafeMethodTest::testHttpMethod()
  2. 10 core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php \Drupal\Tests\Core\PageCache\CommandLineOrUnsafeMethodTest::testHttpMethod()

Asserts that check() returns DENY for unsafe HTTP methods.

@dataProvider providerTestHttpMethod @covers ::check

File

core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php, line 36

Class

CommandLineOrUnsafeMethodTest
@coversDefaultClass \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod @group PageCache

Namespace

Drupal\Tests\Core\PageCache

Code

public function testHttpMethod($expected_result, $method) {
  $this->policy
    ->expects($this
    ->once())
    ->method('isCli')
    ->will($this
    ->returnValue(FALSE));
  $request = Request::create('/', $method);
  $actual_result = $this->policy
    ->check($request);
  $this
    ->assertSame($expected_result, $actual_result);
}