You are here

protected function ServiceControllerTest::setUp 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::setUp()

Overrides UnitTestCase::setUp

File

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

Class

ServiceControllerTest
ServiceController unit tests.

Namespace

Drupal\Tests\cas\Unit\Controller

Code

protected function setUp() {
  parent::setUp();
  $this->casValidator = $this
    ->getMockBuilder('\\Drupal\\cas\\Service\\CasValidator')
    ->disableOriginalConstructor()
    ->getMock();
  $this->casUserManager = $this
    ->getMockBuilder('\\Drupal\\cas\\Service\\CasUserManager')
    ->disableOriginalConstructor()
    ->getMock();
  $this->casLogout = $this
    ->getMockBuilder('\\Drupal\\cas\\Service\\CasLogout')
    ->disableOriginalConstructor()
    ->getMock();
  $this->configFactory = $this
    ->getConfigFactoryStub([
    'cas.settings' => [
      'server.hostname' => 'example-server.com',
      'server.port' => 443,
      'server.path' => '/cas',
      'error_handling.login_failure_page' => '/user/login',
      'error_handling.message_validation_failure' => '/user/login',
      'login_success_message' => '',
    ],
  ]);
  $this->token = $this
    ->prophesize(Token::class);
  $this->casHelper = new CasHelper($this->configFactory, new LoggerChannelFactory(), $this->token
    ->reveal());
  $this->requestStack = $this
    ->createMock('\\Symfony\\Component\\HttpFoundation\\RequestStack');
  $this->urlGenerator = $this
    ->createMock('\\Drupal\\Core\\Routing\\UrlGeneratorInterface');
  $this->requestObject = new Request();
  $request_bag = $this
    ->createMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag');
  $query_bag = $this
    ->createMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag');
  $this->requestObject->query = $query_bag;
  $this->requestObject->request = $request_bag;
  $storage = $this
    ->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockArraySessionStorage')
    ->setMethods(NULL)
    ->getMock();
  $session = $this
    ->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\Session\\Session')
    ->setConstructorArgs([
    $storage,
  ])
    ->setMethods(NULL)
    ->getMock();
  $session
    ->start();
  $this->requestObject
    ->setSession($session);
  $this->requestBag = $request_bag;
  $this->queryBag = $query_bag;
  $this->messenger = $this
    ->createMock('\\Drupal\\Core\\Messenger\\MessengerInterface');
  $this->eventDispatcher = $this
    ->prophesize(ContainerAwareEventDispatcher::class);
  $this->externalAuth = $this
    ->prophesize(ExternalAuthInterface::class);
}