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()); }
/** * @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; }
/** * 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); }
/** * @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'); }
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); }
private function sessionHasNotBeenStarted() { $this->session->expects($this->once())->method('isStarted')->will($this->returnValue(false)); }
/** * 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()); }
public function testOffsetUnset() { $this->session->expects($this->once())->method('remove')->with($this->identicalTo($offset = 'foo')); unset($this->sessionStorage[$offset]); }
public function testRemove() { $this->session->expects($this->once())->method('remove')->with(ProductDataStorage::PRODUCT_DATA_KEY); $this->storage->remove(); }
public function testRedirectAndForget() { $this->sessionStorage->expects($this->once())->method('forget'); $this->testInstance->redirectAndForget(uniqid()); }