function CommandLineOrUnsafeMethodTest::testHttpMethod

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php \Drupal\Tests\Core\PageCache\CommandLineOrUnsafeMethodTest::testHttpMethod()
  2. 8.9.x core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php \Drupal\Tests\Core\PageCache\CommandLineOrUnsafeMethodTest::testHttpMethod()
  3. 11.x 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 43

Class

CommandLineOrUnsafeMethodTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21PageCache%21RequestPolicy%21CommandLineOrUnsafeMethod.php/class/CommandLineOrUnsafeMethod/10" title="Reject when running from the command line or when HTTP method is not safe." class="local">\Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod</a> @group PageCache

Namespace

Drupal\Tests\Core\PageCache

Code

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

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