You are here

protected function RedirectCheckerTest::getRequestStub in Redirect 8

Gets request mock object.

Parameters

string $script_name: The result of the getScriptName() method.

string $method: The request method.

array $attributes: Attributes to be passed into request->attributes.

array $query: Query paramter to be passed into request->query.

Return value

PHPUnit_Framework_MockObject_MockObject Mocked request object.

1 call to RedirectCheckerTest::getRequestStub()
RedirectCheckerTest::testCanRedirect in tests/src/Unit/RedirectCheckerTest.php
Tests the can redirect check.

File

tests/src/Unit/RedirectCheckerTest.php, line 138

Class

RedirectCheckerTest
Tests the redirect logic.

Namespace

Drupal\Tests\redirect\Unit

Code

protected function getRequestStub($script_name, $method, array $attributes = [], array $query = []) {
  $request = $this
    ->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')
    ->disableOriginalConstructor()
    ->getMock();
  $request
    ->expects($this
    ->any())
    ->method('getScriptName')
    ->will($this
    ->returnValue($script_name));
  $request
    ->expects($this
    ->any())
    ->method('isMethod')
    ->with($this
    ->anything())
    ->will($this
    ->returnValue($method == 'GET'));
  $request->query = new ParameterBag($query);
  $request->attributes = new ParameterBag($attributes);
  return $request;
}