本文整理汇总了PHP中Magento\Framework\Session\SessionManagerInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManagerInterface::expects方法的具体用法?PHP SessionManagerInterface::expects怎么用?PHP SessionManagerInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Session\SessionManagerInterface
的用法示例。
在下文中一共展示了SessionManagerInterface::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDelete
public function testDelete()
{
$cookiePath = '/';
$cookieDomain = 'example.com';
/** @var PublicCookieMetadata|\PHPUnit_Framework_MockObject_MockObject $metadata */
$metadata = $this->getMockBuilder('Magento\\Framework\\Stdlib\\Cookie\\PublicCookieMetadata')->disableOriginalConstructor()->getMock();
$this->cookieMetadataFactory->expects(static::once())->method('createCookieMetadata')->willReturn($metadata);
$this->sessionManager->expects(static::once())->method('getCookiePath')->willReturn($cookiePath);
$metadata->expects(static::once())->method('setPath')->with($cookiePath)->willReturnSelf();
$this->sessionManager->expects(static::once())->method('getCookieDomain')->willReturn($cookieDomain);
$metadata->expects(static::once())->method('setDomain')->with($cookieDomain)->willReturnSelf();
$this->cookieManagerMock->expects(static::once())->method('deleteCookie')->with(FormKey::COOKIE_NAME, $metadata);
$this->formKey->delete();
}
示例2: testToHtml
/**
* Run test toHtml method
*
* @param bool $customerId
* @return void
*
* @dataProvider dataProviderToHtml
*/
public function testToHtml($customerId)
{
$cacheData = false;
$idQueryParam = 'id-query-param';
$sessionId = 'session-id';
$this->additional->setData('cache_lifetime', 789);
$this->additional->setData('cache_key', 'cache-key');
$this->eventManagerMock->expects($this->once())->method('dispatch')->with('view_block_abstract_to_html_before', ['block' => $this->additional]);
$this->scopeConfigMock->expects($this->once())->method('getValue')->with('advanced/modules_disable_output/Magento_Persistent', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->willReturn(false);
// get cache
$this->cacheStateMock->expects($this->at(0))->method('isEnabled')->with(\Magento\Persistent\Block\Header\Additional::CACHE_GROUP)->willReturn(true);
// save cache
$this->cacheStateMock->expects($this->at(1))->method('isEnabled')->with(\Magento\Persistent\Block\Header\Additional::CACHE_GROUP)->willReturn(false);
$this->cacheMock->expects($this->once())->method('load')->willReturn($cacheData);
$this->sidResolverMock->expects($this->never())->method('getSessionIdQueryParam')->with($this->sessionMock)->willReturn($idQueryParam);
$this->sessionMock->expects($this->never())->method('getSessionId')->willReturn($sessionId);
// call protected _toHtml method
$sessionMock = $this->getMock('Magento\\Persistent\\Model\\Session', ['getCustomerId'], [], '', false);
$this->persistentSessionHelperMock->expects($this->atLeastOnce())->method('getSession')->willReturn($sessionMock);
$sessionMock->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($customerId);
if ($customerId) {
$this->assertEquals('<span><a >Not you?</a></span>', $this->additional->toHtml());
} else {
$this->assertEquals('', $this->additional->toHtml());
}
}
示例3: testGetDataWithCustomerFormData
public function testGetDataWithCustomerFormData()
{
$customerId = 11;
$customerFormData = ['customer' => ['email' => 'test1@test1.ua', 'default_billing' => 3, 'default_shipping' => 3, 'entity_id' => $customerId], 'address' => [3 => ['firstname' => 'firstname1', 'lastname' => 'lastname1', 'street' => ['street1', 'street2'], 'default_billing' => 3, 'default_shipping' => 3]]];
$customer = $this->getMockBuilder('Magento\\Customer\\Model\\Customer')->disableOriginalConstructor()->getMock();
$address = $this->getMockBuilder('Magento\\Customer\\Model\\Address')->disableOriginalConstructor()->getMock();
$collectionMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\Collection')->disableOriginalConstructor()->getMock();
$collectionMock->expects($this->once())->method('addAttributeToSelect')->with('*');
$this->customerCollectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock);
$collectionMock->expects($this->once())->method('getItems')->willReturn([$customer]);
$customer->expects($this->once())->method('getData')->willReturn(['email' => 'test@test.ua', 'default_billing' => 2, 'default_shipping' => 2]);
$customer->expects($this->once())->method('getId')->willReturn($customerId);
$customer->expects($this->once())->method('getAddresses')->willReturn([$address]);
$address->expects($this->atLeastOnce())->method('getId')->willReturn(2);
$address->expects($this->once())->method('load')->with(2)->willReturnSelf();
$address->expects($this->once())->method('getData')->willReturn(['firstname' => 'firstname', 'lastname' => 'lastname', 'street' => "street\nstreet"]);
$helper = new ObjectManager($this);
$dataProvider = $helper->getObject('\\Magento\\Customer\\Model\\Customer\\DataProvider', ['name' => 'test-name', 'primaryFieldName' => 'primary-field-name', 'requestFieldName' => 'request-field-name', 'eavValidationRules' => $this->eavValidationRulesMock, 'customerCollectionFactory' => $this->customerCollectionFactoryMock, 'eavConfig' => $this->getEavConfigMock()]);
$reflection = new \ReflectionClass(get_class($dataProvider));
$reflectionProperty = $reflection->getProperty('session');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($dataProvider, $this->sessionMock);
$this->sessionMock->expects($this->once())->method('getCustomerFormData')->willReturn($customerFormData);
$this->sessionMock->expects($this->once())->method('unsCustomerFormData');
$this->assertEquals([$customerId => $customerFormData], $dataProvider->getData());
}
示例4: testAroundDispatchCurrencyFromSession
public function testAroundDispatchCurrencyFromSession()
{
$this->sessionMock->expects($this->any())->method('getCurrencyCode')->will($this->returnValue(self::CURRENCY_SESSION));
$this->httpContextMock->expects($this->at(0))->method('setValue')->with(StoreManagerInterface::CONTEXT_STORE, 'custom_store', 'default');
/** Make sure that current currency is taken from session if available */
$this->httpContextMock->expects($this->at(1))->method('setValue')->with(Context::CONTEXT_CURRENCY, self::CURRENCY_SESSION, self::CURRENCY_DEFAULT);
$this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
}
示例5: testAroundDispatch
/**
* Test aroundDispatch
*/
public function testAroundDispatch()
{
$this->storeManagerMock->expects($this->exactly(2))->method('getWebsite')->will($this->returnValue($this->websiteMock));
$this->websiteMock->expects($this->exactly(2))->method('getDefaultStore')->will($this->returnValue($this->storeMock));
$this->storeMock->expects($this->once())->method('getDefaultCurrency')->will($this->returnValue($this->currencyMock));
$this->storeMock->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('storeCookie'));
$this->currencyMock->expects($this->once())->method('getCode')->will($this->returnValue('UAH'));
$this->sessionMock->expects($this->once())->method('getCurrencyCode')->will($this->returnValue('UAH'));
$this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue('default'));
$this->httpContextMock->expects($this->atLeastOnce())->method('setValue')->will($this->returnValueMap([[\Magento\Core\Helper\Data::CONTEXT_CURRENCY, 'UAH', 'UAH', $this->httpContextMock], [\Magento\Core\Helper\Data::CONTEXT_STORE, 'default', 'default', $this->httpContextMock]]));
$this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
}
示例6: testOutput
public function testOutput()
{
$this->sessionManager->expects($this->once())->method('writeClose');
$this->_setupUrlMocks(self::FILE_SIZE, self::URL, ['disposition' => "inline; filename=test.txt"]);
$this->_helper->output();
}
示例7: testSaveByRequest
public function testSaveByRequest()
{
$this->session->expects($this->once())->method('setVisitorData')->will($this->returnSelf());
$this->assertSame($this->visitor, $this->visitor->saveByRequest(null));
}