本文整理汇总了PHP中Magento\Backend\App\ConfigInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigInterface::expects方法的具体用法?PHP ConfigInterface::expects怎么用?PHP ConfigInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Backend\App\ConfigInterface
的用法示例。
在下文中一共展示了ConfigInterface::expects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCheckUpdate
/**
* @dataProvider checkUpdateDataProvider
* @param bool $callInbox
* @param string $curlRequest
*/
public function testCheckUpdate($callInbox, $curlRequest)
{
$mockName = 'Test Product Name';
$mockVersion = '0.0.0';
$mockEdition = 'Test Edition';
$mockUrl = 'http://test-url';
$this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
$this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
$this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
$this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
$configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
$lastUpdate = 0;
$this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
$this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
$this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
$this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
$this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
$this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
$this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
if ($callInbox) {
$this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
$this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
} else {
$this->inboxFactory->expects($this->never())->method('create');
$this->inboxModel->expects($this->never())->method('parse');
}
$this->feed->checkUpdate();
}
示例2: testAuthenticateException
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
* @return void
*/
public function testAuthenticateException()
{
$username = 'username';
$password = 'password';
$config = 'config';
$this->configMock->expects($this->once())->method('isSetFlag')->with('admin/security/use_case_sensitive_login')->willReturn($config);
$this->eventManagerMock->expects($this->any())->method('dispatch');
$this->resourceMock->expects($this->once())->method('loadByUsername')->willThrowException(new \Magento\Framework\Exception\LocalizedException(__()));
$this->model->authenticate($username, $password);
}
示例3: testTrackAdminPassword
public function testTrackAdminPassword()
{
$newPW = "mYn3wpassw0rd";
$uid = 123;
/** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
$eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
/** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
$eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getObject'])->getMock();
/** @var \Magento\User\Model\User|\PHPUnit_Framework_MockObject_MockObject $userMock */
$userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['getId', 'getPassword', 'getForceNewPassword'])->getMock();
$eventObserverMock->expects($this->once())->method('getEvent')->willReturn($eventMock);
$eventMock->expects($this->once())->method('getObject')->willReturn($userMock);
$userMock->expects($this->once())->method('getId')->willReturn($uid);
$userMock->expects($this->once())->method('getPassword')->willReturn($newPW);
$this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
$userMock->expects($this->once())->method('getForceNewPassword')->willReturn(false);
/** @var \Magento\Framework\Message\Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
$collectionMock = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods([])->getMock();
$this->managerInterfaceMock->expects($this->once())->method('getMessages')->willReturn($collectionMock);
$this->authSessionMock->expects($this->once())->method('unsPciAdminUserIsPasswordExpired')->willReturn(null);
$this->model->execute($eventObserverMock);
}
示例4: testCustomerHasFailedMaxNumberOfAttempts
/**
* @return void
*/
public function testCustomerHasFailedMaxNumberOfAttempts()
{
$customerId = 1;
$date = new \DateTime();
$date->modify('-500 second');
$formattedDate = $date->format('Y-m-d H:i:s');
$this->backendConfigMock->expects($this->exactly(2))->method('getValue')->withConsecutive([\Magento\Customer\Helper\AccountManagement::LOCKOUT_THRESHOLD_PATH], [\Magento\Customer\Helper\AccountManagement::MAX_FAILURES_PATH])->willReturnOnConsecutiveCalls(10, 5);
$this->customerRegistryMock->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecure);
$this->customerSecure->expects($this->once())->method('getFailuresNum')->willReturn(5);
$this->customerSecure->expects($this->once())->method('getFirstFailure')->willReturn($formattedDate);
$this->customerSecure->expects($this->once())->method('setLockExpires');
$this->customerSecure->expects($this->once())->method('setFailuresNum');
$this->helper->processCustomerLockoutData($customerId);
}
示例5: testForceAdminPasswordChange
public function testForceAdminPasswordChange()
{
/** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
$eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
/** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
$eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getControllerAction', 'getRequest'])->getMock();
$this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
$this->authSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
$eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
/** @var \Magento\Framework\App\Action\Action $controllerMock */
$controllerMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\AbstractAction')->disableOriginalConstructor()->setMethods(['getRedirect', 'getRequest'])->getMockForAbstractClass();
/** @var \Magento\Framework\App\RequestInterface $requestMock */
$requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getFullActionName', 'setDispatched'])->getMockForAbstractClass();
$eventMock->expects($this->once())->method('getControllerAction')->willReturn($controllerMock);
$eventMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
$this->authSessionMock->expects($this->once())->method('getPciAdminUserIsPasswordExpired')->willReturn(true);
$requestMock->expects($this->once())->method('getFullActionName')->willReturn('not_in_array');
$this->authSessionMock->expects($this->once())->method('clearStorage');
$this->sessionMock->expects($this->once())->method('clearStorage');
$this->managerInterfaceMock->expects($this->once())->method('addErrorMessage');
$controllerMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
$requestMock->expects($this->once())->method('setDispatched')->willReturn(false);
$this->model->execute($eventObserverMock);
}
示例6: testSendPasswordResetConfirmationEmail
public function testSendPasswordResetConfirmationEmail()
{
$storeId = 0;
$email = 'test@example.com';
$firstName = 'Foo';
$lastName = 'Bar';
$this->_model->setEmail($email);
$this->_model->setFirstname($firstName);
$this->_model->setLastname($lastName);
$this->_configMock->expects($this->at(0))->method('getValue')->with(\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_TEMPLATE)->will($this->returnValue('templateId'));
$this->_configMock->expects($this->at(1))->method('getValue')->with(\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_IDENTITY)->will($this->returnValue('sender'));
$this->_transportBuilderMock->expects($this->once())->method('setTemplateOptions')->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(['user' => $this->_model, 'store' => $this->_storetMock])->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('addTo')->with($this->equalTo($email), $this->equalTo($firstName . ' ' . $lastName))->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('setFrom')->with('sender')->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with('templateId')->will($this->returnSelf());
$this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transportMock));
$this->_transportMock->expects($this->once())->method('sendMessage');
$this->_storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnValue($this->_storetMock));
$this->assertInstanceOf('\\Magento\\User\\Model\\User', $this->_model->sendPasswordResetConfirmationEmail());
}
示例7: testValidateCustomerPassword
/**
* @param bool $result
* @dataProvider validateCustomerPassword
*/
public function testValidateCustomerPassword($result)
{
$customerId = 7;
$password = '1234567';
$hash = '1b2af329dd0';
$customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
$this->customerRepositoryMock->expects($this->any())->method('getById')->willReturn($customerMock);
$this->customerSecure->expects($this->any())->method('getId')->willReturn($customerId);
$this->customerSecure->expects($this->once())->method('getPasswordHash')->willReturn($hash);
$this->customerRegistryMock->expects($this->any())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecure);
$this->encryptorMock->expects($this->once())->method('validateHash')->with($password, $hash)->willReturn($result);
if ($result) {
$this->assertTrue($this->authentication->authenticate($customerId, $password));
} else {
$this->backendConfigMock->expects($this->exactly(2))->method('getValue')->withConsecutive([\Magento\Customer\Model\Authentication::LOCKOUT_THRESHOLD_PATH], [\Magento\Customer\Model\Authentication::MAX_FAILURES_PATH])->willReturnOnConsecutiveCalls(1, 1);
$this->customerSecure->expects($this->once())->method('isCustomerLocked')->willReturn(false);
$this->customerRegistryMock->expects($this->once())->method('retrieve')->with($customerId)->willReturn($this->customerSecure);
$this->customerRepositoryMock->expects($this->once())->method('save')->willReturn($customerMock);
$this->setExpectedException('\\Magento\\Framework\\Exception\\InvalidEmailOrPasswordException');
$this->authentication->authenticate($customerId, $password);
}
}
示例8: testAdminAuthenticateUpdateLockingInfo
public function testAdminAuthenticateUpdateLockingInfo()
{
$password = "myP@sw0rd";
$uid = 123;
$authResult = false;
$firstFailure = '1965-07-08 11:14:15.638276';
$numOfFailures = 5;
/** @var Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
$eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
/** @var Event|\PHPUnit_Framework_MockObject_MockObject */
$eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getPassword', 'getUser', 'getResult'])->getMock();
/** @var ModelUser|\PHPUnit_Framework_MockObject_MockObject $userMock */
$userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['getId', 'getFailuresNum', 'getFirstFailure'])->getMock();
$eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
$eventMock->expects($this->once())->method('getPassword')->willReturn($password);
$eventMock->expects($this->once())->method('getUser')->willReturn($userMock);
$eventMock->expects($this->once())->method('getResult')->willReturn($authResult);
$userMock->expects($this->once())->method('getId')->willReturn($uid);
$this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
$userMock->expects($this->once())->method('getFailuresNum')->willReturn($numOfFailures);
$userMock->expects($this->once())->method('getFirstFailure')->willReturn($firstFailure);
$this->userMock->expects($this->once())->method('updateFailure');
$this->model->execute($eventObserverMock);
}
示例9: testGetResetPasswordLinkExpirationPeriod
public function testGetResetPasswordLinkExpirationPeriod()
{
$value = '123';
$this->configMock->expects($this->once())->method('getValue')->with(\Magento\User\Helper\Data::XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD)->willReturn($value);
$this->assertEquals((int) $value, $this->model->getResetPasswordLinkExpirationPeriod());
}
示例10: testGetUserInterfaceGeneralLocale
/**
* @covers \Magento\Backend\Model\Locale\Manager::getUserInterfaceLocale
*/
public function testGetUserInterfaceGeneralLocale()
{
$this->_backendConfig->expects($this->any())->method('getValue')->with('general/locale/code')->willReturn('test_locale');
$locale = $this->_model->getUserInterfaceLocale();
$this->assertEquals($locale, 'test_locale');
}
示例11: testGetDefaultPath
public function testGetDefaultPath()
{
$this->backendConfig->expects($this->once())->method('getValue')->with('web/default/admin')->willReturn('default/path');
$this->assertEquals('default/path', $this->adminPathConfig->getDefaultPath());
}