You are here

public function ServiceControllerTest::testSuccessfulLogin in CAS 8

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

Tests that validation and logging in occurs when a ticket is present.

@dataProvider parameterDataProvider

File

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

Class

ServiceControllerTest
ServiceController unit tests.

Namespace

Drupal\Tests\cas\Unit\Controller

Code

public function testSuccessfulLogin($returnto) {
  $this
    ->setupRequestParameters($returnto, FALSE, TRUE);
  $this->requestStack
    ->expects($this
    ->once())
    ->method('getCurrentRequest')
    ->will($this
    ->returnValue($this->requestObject));
  if ($returnto) {
    $this
      ->assertDestinationSetFromReturnTo();
  }
  $validation_data = new CasPropertyBag('testuser');
  $this
    ->assertSuccessfulValidation($returnto);

  // Login should be called.
  $this->casUserManager
    ->expects($this
    ->once())
    ->method('login')
    ->with($this
    ->equalTo($validation_data), $this
    ->equalTo('ST-foobar'));
  $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
    ->assertRedirectedToFrontPageOnHandle($serviceController);
}