public function CasRedirectorTest::testEventsDispatched in CAS 2.x
Same name and namespace in other branches
- 8 tests/src/Unit/Service/CasRedirectorTest.php \Drupal\Tests\cas\Unit\Service\CasRedirectorTest::testEventsDispatched()
Tests the events dispatched by the listener.
@covers ::buildRedirectResponse
File
- tests/
src/ Unit/ Service/ CasRedirectorTest.php, line 192
Class
- CasRedirectorTest
- Cas Redirector Unit Tests.
Namespace
Drupal\Tests\cas\Unit\ServiceCode
public function testEventsDispatched() {
// Mock up listener on dispatched event.
$this->eventDispatcher
->method('dispatch')
->willReturnCallback([
$this,
'dispatchEvent',
]);
$this->events = [];
// Fire the redirection event.
$cas_redirector = new CasRedirector($this->casHelper, $this->eventDispatcher, $this->urlGenerator, $this->configFactory);
$cas_data = new CasRedirectData();
$response = $cas_redirector
->buildRedirectResponse($cas_data);
// Verfiy that the event fired and the redirector was appropriately altered.
$this
->assertEquals(1, count($this->events), 'One Event was fired');
$this
->assertEquals('https://example-server.com/cas/login?strong_auth=true&service=http%3A//example.com/casservice', $response
->getTargetUrl(), 'Altered parameters');
}