public function CasRedirectorTest::setUp in CAS 8
Same name and namespace in other branches
- 2.x tests/src/Unit/Service/CasRedirectorTest.php \Drupal\Tests\cas\Unit\Service\CasRedirectorTest::setUp()
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ Service/ CasRedirectorTest.php, line 62
Class
- CasRedirectorTest
- Cas Redirector Unit Tests.
Namespace
Drupal\Tests\cas\Unit\ServiceCode
public function setUp() {
parent::setUp();
$this->configFactory = $this
->getConfigFactoryStub([
'cas.settings' => [
'server.hostname' => 'example-server.com',
'server.protocol' => 'https',
'server.port' => 443,
'server.path' => '/cas',
'server.version' => '2.0',
'server.verify' => CasHelper::CA_DEFAULT,
'server.cert' => 'foo',
'advanced.connection_timeout' => 30,
],
]);
$this->casHelper = $this
->getMockBuilder('\\Drupal\\cas\\Service\\CasHelper')
->disableOriginalConstructor()
->getMock();
$this->urlGenerator = $this
->createMock('\\Drupal\\Core\\Routing\\UrlGeneratorInterface');
$this->urlGenerator
->method('generate')
->willReturnCallback([
$this,
'getServiceUrl',
]);
// Mock event dispatcher to dispatch events.
$this->eventDispatcher = $this
->getMockBuilder('\\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')
->disableOriginalConstructor()
->getMock();
// We have to mock the cache context manager which is called when we
// add cache contexts to a cacheable metadata.
$cache_contexts_manager = $this
->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')
->disableOriginalConstructor()
->getMock();
$cache_contexts_manager
->method('assertValidTokens')
->willReturn(TRUE);
$container = new Container();
$container
->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($container);
}