/**
  * Sets up this test case
  */
 public function setUp()
 {
     $this->securityContext = $this->getAccessibleMock(\TYPO3\Flow\Security\Context::class, array('separateActiveAndInactiveTokens'));
     $this->mockAuthenticationManager = $this->getMock(\TYPO3\Flow\Security\Authentication\AuthenticationManagerInterface::class);
     $this->mockAuthenticationManager->expects($this->any())->method('getTokens')->will($this->returnValue(array()));
     $this->securityContext->injectAuthenticationManager($this->mockAuthenticationManager);
     $this->mockActionRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->securityContext->setRequest($this->mockActionRequest);
 }
 /**
  * @param array $patterns
  * @param bool $expectedActive
  * @test
  * @dataProvider separateActiveAndInactiveTokensDataProvider
  */
 public function separateActiveAndInactiveTokensTests(array $patterns, $expectedActive)
 {
     $mockRequestPatterns = [];
     foreach ($patterns as $pattern) {
         $mockRequestPattern = $this->getMockBuilder(\TYPO3\Flow\Security\RequestPatternInterface::class)->setMockClassName('RequestPattern_' . $pattern['type'])->getMock();
         $mockRequestPattern->expects($this->any())->method('matchRequest')->with($this->mockActionRequest)->will($this->returnValue($pattern['matchesRequest']));
         $mockRequestPatterns[] = $mockRequestPattern;
     }
     $mockToken = $this->createMock(\TYPO3\Flow\Security\Authentication\TokenInterface::class);
     $mockToken->expects($this->once())->method('hasRequestPatterns')->will($this->returnValue($mockRequestPatterns !== []));
     $mockToken->expects($this->any())->method('getRequestPatterns')->will($this->returnValue($mockRequestPatterns));
     /** @var \TYPO3\Flow\Security\Authentication\AuthenticationManagerInterface|\PHPUnit_Framework_MockObject_MockObject $mockAuthenticationManager */
     $mockAuthenticationManager = $this->createMock(\TYPO3\Flow\Security\Authentication\AuthenticationManagerInterface::class);
     $mockAuthenticationManager->expects($this->once())->method('getTokens')->will($this->returnValue([$mockToken]));
     $this->securityContext = $this->getAccessibleMock(Context::class, ['dummy']);
     $settings = [];
     $settings['security']['authentication']['authenticationStrategy'] = 'allTokens';
     $this->securityContext->injectSettings($settings);
     $this->securityContext->injectAuthenticationManager($mockAuthenticationManager);
     $this->securityContext->setRequest($this->mockActionRequest);
     $this->securityContext->initialize();
     if ($expectedActive) {
         $this->assertContains($mockToken, $this->securityContext->_get('activeTokens'));
     } else {
         $this->assertContains($mockToken, $this->securityContext->_get('inactiveTokens'));
     }
 }