public function getCsrfProtectionTokenReturnsANewTokenIfNoneIsPresentInTheContext() { $mockAuthenticationManager = $this->createMock(AuthenticationManagerInterface::class); /** @var Context $securityContext */ $securityContext = $this->getAccessibleMock(Context::class, ['getAuthenticationTokens']); $securityContext->setRequest($this->mockActionRequest); $securityContext->_set('authenticationManager', $mockAuthenticationManager); $securityContext->_set('csrfTokens', []); $this->assertNotEmpty($securityContext->getCsrfProtectionToken()); }