public function RequestSubscriberTest::testRequestSubscriberAnonymous in CRM Core 8
Same name and namespace in other branches
- 8.3 modules/crm_core_user_sync/tests/src/Unit/RequestSubscriberTest.php \Drupal\Tests\crm_core_user_sync\Unit\RequestSubscriberTest::testRequestSubscriberAnonymous()
Tests nothing happens for Anonymous.
File
- modules/
crm_core_user_sync/ tests/ src/ Unit/ RequestSubscriberTest.php, line 29
Class
- RequestSubscriberTest
- Test description.
Namespace
Drupal\Tests\crm_core_user_sync\UnitCode
public function testRequestSubscriberAnonymous() {
$current_user = $this
->createMock(AccountProxyInterface::class);
$current_user
->expects($this
->once())
->method('isAuthenticated')
->willReturn(FALSE);
$configFactory = $this
->createMock(ConfigFactoryInterface::class);
$configFactory
->expects($this
->never())
->method('get');
$relationService = $this
->createMock(CrmCoreUserSyncRelationInterface::class);
$entityTypeManager = $this
->createMock(EntityTypeManagerInterface::class);
$entityTypeManager
->expects($this
->never())
->method('getStorage');
$kernel = $this
->prophesize(HttpKernelInterface::class);
$request = Request::create('/', 'GET');
$subscriber = new RequestSubscriber($current_user, $configFactory, $relationService, $entityTypeManager);
$event = new GetResponseEvent($kernel
->reveal(), $request, HttpKernelInterface::MASTER_REQUEST);
$subscriber
->onKernelRequest($event);
// Nothing to assert as we should exit immediately. Current user expectation
// will fail the test if something...
}