/** * @covers \Magento\Persistent\Model\Session::_afterDeleteCommit * @covers \Magento\Persistent\Model\Session::removePersistentCookie */ public function testAfterDeleteCommit() { $cookiePath = 'some_path'; $this->_configMock->expects($this->once())->method('getCookiePath')->will($this->returnValue($cookiePath)); $this->_cookieMock->expects($this->once())->method('set')->with(\Magento\Persistent\Model\Session::COOKIE_NAME, $this->anything(), $this->anything(), $cookiePath); $this->_model->delete(); }
/** * @covers \Magento\Persistent\Model\Session::removePersistentCookie */ public function testAfterDeleteCommit() { $cookiePath = 'some_path'; $this->configMock->expects($this->once())->method('getCookiePath')->will($this->returnValue($cookiePath)); $cookieMetadataMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\Cookie\\SensitiveCookieMetadata')->disableOriginalConstructor()->getMock(); $cookieMetadataMock->expects($this->once())->method('setPath')->with($cookiePath)->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->once())->method('createSensitiveCookieMetadata')->will($this->returnValue($cookieMetadataMock)); $this->cookieManagerMock->expects($this->once())->method('deleteCookie')->with(\Magento\Persistent\Model\Session::COOKIE_NAME, $cookieMetadataMock); $this->session->afterDeleteCommit(); }
public function testExecute() { $formKey = 'form_key'; $escapedFormKey = 'escaped_form_key'; $cookieDomain = 'example.com'; $cookiePath = '/'; $cookieLifetime = 3600; $cookieMetadata = $this->getMockBuilder('Magento\\Framework\\Stdlib\\Cookie\\PublicCookieMetadata')->disableOriginalConstructor()->getMock(); $this->cookieFormKey->expects(static::any())->method('get')->willReturn($formKey); $this->cookieMetadataFactory->expects(static::once())->method('createPublicCookieMetadata')->willReturn($cookieMetadata); $this->sessionConfig->expects(static::once())->method('getCookieDomain')->willReturn($cookieDomain); $cookieMetadata->expects(static::once())->method('setDomain')->with($cookieDomain); $this->sessionConfig->expects(static::once())->method('getCookiePath')->willReturn($cookiePath); $cookieMetadata->expects(static::once())->method('setPath')->with($cookiePath); $this->sessionConfig->expects(static::once())->method('getCookieLifetime')->willReturn($cookieLifetime); $cookieMetadata->expects(static::once())->method('setDuration')->with($cookieLifetime); $this->cookieFormKey->expects(static::once())->method('set')->with($formKey, $cookieMetadata); $this->escaper->expects(static::once())->method('escapeHtml')->with($formKey)->willReturn($escapedFormKey); $this->sessionFormKey->expects(static::once())->method('set')->with($escapedFormKey); $this->observer->execute($this->observerMock); }
public function testGetLifetime() { $lifetime = 3600; $this->sessionConfigMock->expects(static::once())->method('getCookieLifetime')->willReturn($lifetime); $this->assertEquals($lifetime, $this->model->getLifetime()); }