You are here

public function ServiceControllerTest::testTicketValidationError in CAS 2.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/Controller/ServiceControllerTest.php \Drupal\Tests\cas\Unit\Controller\ServiceControllerTest::testTicketValidationError()

Tests for a potential validation error.

@dataProvider parameterDataProvider

File

tests/src/Unit/Controller/ServiceControllerTest.php, line 380

Class

ServiceControllerTest
ServiceController unit tests.

Namespace

Drupal\Tests\cas\Unit\Controller

Code

public function testTicketValidationError($returnto) {
  $this
    ->setupRequestParameters($returnto, FALSE, TRUE);
  $this->requestStack
    ->expects($this
    ->once())
    ->method('getCurrentRequest')
    ->will($this
    ->returnValue($this->requestObject));

  // Validation should throw an exception.
  $this->casValidator
    ->expects($this
    ->once())
    ->method('validateTicket')
    ->will($this
    ->throwException(new CasValidateException()));

  // Login should not be called.
  $this->casUserManager
    ->expects($this
    ->never())
    ->method('login');
  $serviceController = new ServiceController($this->casHelper, $this->casValidator, $this->casUserManager, $this->casLogout, $this->requestStack, $this->urlGenerator, $this->configFactory, $this->messenger, $this->eventDispatcher
    ->reveal(), $this->externalAuth
    ->reveal());
  $serviceController
    ->setStringTranslation($this
    ->getStringTranslationStub());
  $this
    ->assertRedirectedToSpecialPageOnLoginFailure($serviceController);
}