public function testGetShowTierPricesWithRequestAndSaveState()
 {
     $this->handler->setRequest($this->request);
     $this->request->expects($this->exactly(3))->method('get')->willReturnMap([[FrontendPriceListRequestHandler::TIER_PRICES_KEY, null, false, '1'], [FrontendPriceListRequestHandler::SAVE_STATE_KEY, null, false, true]]);
     $this->session->expects($this->once())->method('set')->with(FrontendPriceListRequestHandler::TIER_PRICES_KEY, true);
     $this->assertEquals(true, $this->handler->getShowTierPrices());
 }
コード例 #2
0
 /**
  * @return \Symfony\Component\HttpFoundation\Session\SessionInterface|PHPUnit_Framework_MockObject_MockObject
  */
 protected function getSessionMock()
 {
     if (!isset($this->sessionMock)) {
         $this->sessionMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface');
         $this->sessionMock->expects($this->atLeastOnce())->method('isStarted')->will($this->returnValue($this->sessionIsStarted));
     }
     return $this->sessionMock;
 }
コード例 #3
0
 /**
  * Tests onLogout() method.
  */
 public function testOnLogout()
 {
     // Given
     $event = $this->getMock('Parenthesis\\WPBundle\\Event\\WordpressEvent');
     // When - Then
     $this->session->expects($this->once())->method('clear');
     $this->tokenStorage->expects($this->once())->method('setToken')->with(null);
     $this->listener->onLogout($event);
 }
コード例 #4
0
  /**
   * @covers ::getContext
   */
  public function testDifferentContextForDifferentSession() {
    $session1_id = 'pjH_8aSoofyCDQiuVYXJcbfyr-CPtkUY';
    $this->session->expects($this->at(0))
      ->method('getId')
      ->will($this->returnValue($session1_id));

    $session2_id = 'aSebeZ52bbM6SvADurQP89SFnEpxY6j8';
    $this->session->expects($this->at(1))
      ->method('getId')
      ->will($this->returnValue($session2_id));

    $context1 = $this->cacheContext->getContext();
    $context2 = $this->cacheContext->getContext();
    $this->assertNotEquals($context1, $context2);

    $this->assertSame(FALSE, strpos($context1, $session1_id), 'Session ID not contained in cache context');
    $this->assertSame(FALSE, strpos($context2, $session2_id), 'Session ID not contained in cache context');
  }
コード例 #5
0
 public function testAuthenticatedWithInvalidNetizen()
 {
     $token = new Token('secu', 'dummy', '123456');
     $user = new Netizen(new Author('kirk'));
     $token->setUser($user);
     $event = $this->createEvent(new AccessDeniedHttpException());
     $this->security->expects($this->once())->method('getToken')->willReturn($token);
     $this->security->expects($this->once())->method('isGranted')->with(TicketVoter::SUPPORTED_ATTRIBUTE)->willReturn(false);
     $bag = new \Symfony\Component\HttpFoundation\Session\Flash\FlashBag();
     $this->session->expects($this->once())->method('getFlashBag')->willReturn($bag);
     $this->sut->onKernelException($event);
     $this->assertTrue($event->hasResponse());
     $this->assertCount(1, $bag);
 }
コード例 #6
0
 private function sessionHasNotBeenStarted()
 {
     $this->session->expects($this->once())->method('isStarted')->will($this->returnValue(false));
 }
コード例 #7
0
 /**
  * Test referrer is search engine.
  *
  * @dataProvider dataReferrerIsSearchEngine
  */
 public function testReferrerIsSearchEngine($referrer, $isSearchEngine)
 {
     $this->session->expects($this->any())->method('get')->will($this->returnValue($referrer));
     $this->assertEquals($isSearchEngine, $this->referrerProvider->referrerIsSearchEngine());
 }
コード例 #8
0
ファイル: SessionStorageTest.php プロジェクト: blazarecki/lug
 public function testOffsetUnset()
 {
     $this->session->expects($this->once())->method('remove')->with($this->identicalTo($offset = 'foo'));
     unset($this->sessionStorage[$offset]);
 }
コード例 #9
0
 public function testRemove()
 {
     $this->session->expects($this->once())->method('remove')->with(ProductDataStorage::PRODUCT_DATA_KEY);
     $this->storage->remove();
 }
コード例 #10
0
 public function testRedirectAndForget()
 {
     $this->sessionStorage->expects($this->once())->method('forget');
     $this->testInstance->redirectAndForget(uniqid());
 }