Exemplo n.º 1
0
 /**
  * Test delete logout reason cookie
  * @return void
  */
 public function testDeleteLogoutReasonCookie()
 {
     $frontName = 'FrontName';
     $this->createCookieMetaData();
     $this->backendDataMock->expects($this->once())->method('getAreaFrontName')->willReturn($frontName);
     $this->cookieMetadataMock->expects($this->once())->method('setPath')->with('/' . $frontName)->willReturnSelf();
     $this->cookieMetadataMock->expects($this->once())->method('setDuration')->with(-1)->willReturnSelf();
     $this->phpCookieManagerMock->expects($this->once())->method('setPublicCookie')->with(SecurityCookie::LOGOUT_REASON_CODE_COOKIE_NAME, '', $this->cookieMetadataMock)->willReturnSelf();
     $this->assertEquals($this->model, $this->model->deleteLogoutReasonCookie());
 }
Exemplo n.º 2
0
 /**
  * @param bool $result
  * @param string $callCount
  * @return void
  * @dataProvider testBeforeStartDataProvider
  */
 public function testBeforeStart($result, $callCount)
 {
     $phpSessionCookieName = 'PHPSESSID';
     $frontendSessionCookieName = 'mage-cache-sessid';
     $this->sessionManager->expects($this->once())->method('getName')->willReturn($phpSessionCookieName);
     $this->cookieManager->expects($this->exactly(2))->method('getCookie')->withConsecutive([$phpSessionCookieName], [$frontendSessionCookieName])->willReturnOnConsecutiveCalls(false, $result);
     $this->metadataFactory->expects($this->{$callCount}())->method('createCookieMetadata')->willReturn($this->metadata);
     $this->metadata->expects($this->{$callCount}())->method('setPath')->with('/');
     $this->cookieManager->expects($this->{$callCount}())->method('deleteCookie')->with('mage-cache-sessid', $this->metadata);
     $this->plugin->beforeStart($this->sessionManager);
 }
Exemplo n.º 3
0
 public function testExecute()
 {
     $customerId = 1;
     $refererUrl = 'http://referer.url';
     $this->sessionMock->expects($this->once())->method('getId')->willReturn($customerId);
     $this->sessionMock->expects($this->once())->method('logout')->willReturnSelf();
     $this->redirect->expects($this->once())->method('getRefererUrl')->willReturn($refererUrl);
     $this->sessionMock->expects($this->once())->method('setBeforeAuthUrl')->with($refererUrl)->willReturnSelf();
     $this->sessionMock->expects($this->once())->method('setLastCustomerId')->with($customerId);
     $this->cookieManager->expects($this->once())->method('getCookie')->with('mage-cache-sessid')->willReturn(true);
     $this->cookieMetadataFactory->expects($this->once())->method('createCookieMetadata')->willReturn($this->cookieMetadata);
     $this->cookieMetadata->expects($this->once())->method('setPath')->with('/');
     $this->cookieManager->expects($this->once())->method('deleteCookie')->with('mage-cache-sessid', $this->cookieMetadata);
     $this->redirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->resultRedirect->expects($this->once())->method('setPath')->with('*/*/logoutSuccess');
     $this->assertSame($this->resultRedirect, $this->controller->execute());
 }