コード例 #1
0
 public function testSetPersistentCookie()
 {
     $this->assertArrayNotHasKey(Session::COOKIE_NAME, $_COOKIE);
     $key = 'sessionKey';
     $this->session->setKey($key);
     $this->session->setPersistentCookie(1000, '/');
     $this->assertEquals($key, $_COOKIE[Session::COOKIE_NAME]);
 }
コード例 #2
0
 public function testSetPersistentCookie()
 {
     $cookiePath = 'some_path';
     $duration = 1000;
     $key = 'sessionKey';
     $this->session->setKey($key);
     $cookieMetadataMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\Cookie\\PublicCookieMetadata')->disableOriginalConstructor()->getMock();
     $cookieMetadataMock->expects($this->once())->method('setPath')->with($cookiePath)->will($this->returnSelf());
     $cookieMetadataMock->expects($this->once())->method('setDuration')->with($duration)->will($this->returnSelf());
     $this->cookieMetadataFactoryMock->expects($this->once())->method('createPublicCookieMetadata')->will($this->returnValue($cookieMetadataMock));
     $this->cookieManagerMock->expects($this->once())->method('setPublicCookie')->with(\Magento\Persistent\Model\Session::COOKIE_NAME, $key, $cookieMetadataMock);
     $this->session->setPersistentCookie($duration, $cookiePath);
 }