private function ServiceControllerTest::setupRequestParameters in CAS 8
Same name and namespace in other branches
- 2.x tests/src/Unit/Controller/ServiceControllerTest.php \Drupal\Tests\cas\Unit\Controller\ServiceControllerTest::setupRequestParameters()
Mock our request and query bags for the provided parameters.
This method accepts each possible parameter that the Sevice Controller may need to deal with. Each parameter passed in should just be TRUE or FALSE. If it's TRUE, we also mock the "get" method for the appropriate parameter bag to return some predefined value.
Parameters
bool $returnto: If returnto param should be set.
bool $logout_request: If logoutRequest param should be set.
bool $ticket: If ticket param should be set.
7 calls to ServiceControllerTest::setupRequestParameters()
- ServiceControllerTest::testEventListenerChangesCasUsername in tests/
src/ Unit/ Controller/ ServiceControllerTest.php - An event listener alters username before attempting to load user.
- ServiceControllerTest::testLoginError in tests/
src/ Unit/ Controller/ ServiceControllerTest.php - Tests for a potential login error.
- ServiceControllerTest::testMissingTicketRedirectsHome in tests/
src/ Unit/ Controller/ ServiceControllerTest.php - Tests that we redirect to the homepage when no service ticket is present.
- ServiceControllerTest::testSingleLogout in tests/
src/ Unit/ Controller/ ServiceControllerTest.php - Tests a single logout request.
- ServiceControllerTest::testSuccessfulLogin in tests/
src/ Unit/ Controller/ ServiceControllerTest.php - Tests that validation and logging in occurs when a ticket is present.
File
- tests/
src/ Unit/ Controller/ ServiceControllerTest.php, line 622
Class
- ServiceControllerTest
- ServiceController unit tests.
Namespace
Drupal\Tests\cas\Unit\ControllerCode
private function setupRequestParameters($returnto, $logout_request, $ticket) {
// Request params.
$map = [
[
'logoutRequest',
$logout_request,
],
];
$this->requestBag
->expects($this
->any())
->method('has')
->will($this
->returnValueMap($map));
$map = [];
if ($logout_request === TRUE) {
$map[] = [
'logoutRequest',
NULL,
'<foobar/>',
];
}
if (!empty($map)) {
$this->requestBag
->expects($this
->any())
->method('get')
->will($this
->returnValueMap($map));
}
// Query string params.
$map = [
[
'returnto',
$returnto,
],
[
'ticket',
$ticket,
],
];
$this->queryBag
->expects($this
->any())
->method('has')
->will($this
->returnValueMap($map));
$map = [];
if ($returnto === TRUE) {
$map[] = [
'returnto',
NULL,
'node/1',
];
}
if ($ticket === TRUE) {
$map[] = [
'ticket',
NULL,
'ST-foobar',
];
}
if (!empty($map)) {
$this->queryBag
->expects($this
->any())
->method('get')
->will($this
->returnValueMap($map));
}
// Query string "all" method should include all params.
$all = [];
if ($returnto) {
$all['returnto'] = 'node/1';
}
if ($ticket) {
$all['ticket'] = 'ST-foobar';
}
$this->queryBag
->method('all')
->will($this
->returnValue($all));
}