本文整理汇总了PHP中Magento\Framework\Exception\NoSuchEntityException::doubleField方法的典型用法代码示例。如果您正苦于以下问题:PHP NoSuchEntityException::doubleField方法的具体用法?PHP NoSuchEntityException::doubleField怎么用?PHP NoSuchEntityException::doubleField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Exception\NoSuchEntityException
的用法示例。
在下文中一共展示了NoSuchEntityException::doubleField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDoubleField
/**
* @return void
*/
public function testDoubleField()
{
$website = 'website';
$websiteValue = 15;
$email = 'email';
$emailValue = 'example@magento.com';
NoSuchEntityException::doubleField($website, $websiteValue, $email, $emailValue);
$this->assertSame("No such entity with {$website} = {$websiteValue}, {$email} = {$emailValue}", NoSuchEntityException::doubleField($website, $websiteValue, $email, $emailValue)->getMessage());
}
示例2: testSendPasswordResetLinkBadEmailOrWebsite
public function testSendPasswordResetLinkBadEmailOrWebsite()
{
$email = 'foo@example.com';
$this->_customerRegistry->expects($this->any())->method('retrieveByEmail')->will($this->throwException(NoSuchEntityException::doubleField('email', $email, 'websiteId', 0)));
$this->_customerModelMock->expects($this->never())->method('sendPasswordResetConfirmationEmail');
$customerService = $this->_createService();
try {
$customerService->initiatePasswordReset($email, CustomerAccountServiceInterface::EMAIL_RESET, 0);
$this->fail("Expected NoSuchEntityException not caught");
} catch (NoSuchEntityException $nsee) {
$this->assertSame("No such entity with email = foo@example.com, websiteId = 0", $nsee->getMessage());
}
}
示例3: _isUserWithRoleAllowed
/**
* Check if user who has role is allowed to access requested resources.
*
* @param string[] $resources
* @param UserIdentifier $userIdentifier
* @return bool
*/
protected function _isUserWithRoleAllowed($resources, UserIdentifier $userIdentifier)
{
try {
$role = $this->_getUserRole($userIdentifier);
if (!$role) {
throw NoSuchEntityException::doubleField('userId', $userIdentifier->getUserId(), 'userType', $userIdentifier->getUserType());
}
foreach ($resources as $resource) {
if (!$this->_aclBuilder->getAcl()->isAllowed($role->getId(), $resource)) {
return false;
}
}
return true;
} catch (\Exception $e) {
$this->_logger->logException($e);
return false;
}
}
示例4: getDefaultGroup
/**
* {@inheritdoc}
*/
public function getDefaultGroup($storeId = null)
{
if ($storeId === null) {
$storeId = $this->storeManager->getStore()->getCode();
}
try {
$groupId = $this->scopeConfig->getValue(self::XML_PATH_DEFAULT_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} catch (\Magento\Framework\Exception\State\InitException $e) {
throw NoSuchEntityException::singleField('storeId', $storeId);
} catch (NoSuchEntityException $e) {
throw NoSuchEntityException::singleField('storeId', $storeId);
}
try {
return $this->groupRepository->getById($groupId);
} catch (NoSuchEntityException $e) {
throw NoSuchEntityException::doubleField('groupId', $groupId, 'storeId', $storeId);
}
}
示例5: getDefaultGroup
/**
* {@inheritdoc}
*/
public function getDefaultGroup($storeId = null)
{
if (is_null($storeId)) {
$storeId = $this->_storeManager->getStore()->getCode();
}
try {
$groupId = $this->_scopeConfig->getValue(CustomerGroupModel::XML_PATH_DEFAULT_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} catch (\Magento\Framework\Model\Exception $e) {
throw NoSuchEntityException::singleField('storeId', $storeId);
}
try {
return $this->getGroup($groupId);
} catch (NoSuchEntityException $e) {
throw NoSuchEntityException::doubleField('groupId', $groupId, 'storeId', $storeId);
}
}
示例6: testCreateCustomerWithoutAddressRequiresException
/**
* Test creating a customer with absent required address fields
*/
public function testCreateCustomerWithoutAddressRequiresException()
{
$customerDataArray = $this->dataObjectProcessor->buildOutputDataArray($this->customerHelper->createSampleCustomerDataObject(), '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
foreach ($customerDataArray[Customer::KEY_ADDRESSES] as &$address) {
$address[Address::FIRSTNAME] = null;
}
$serviceInfo = ['rest' => ['resourcePath' => self::RESOURCE_PATH, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST], 'soap' => ['service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_NAME . 'Save']];
$requestData = ['customer' => $customerDataArray];
try {
$this->_webApiCall($serviceInfo, $requestData);
$this->fail('Expected exception did not occur.');
} catch (\Exception $e) {
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
$expectedException = new InputException();
$expectedException->addError(__('%fieldName is a required field.', ['fieldName' => Address::FIRSTNAME]));
$this->assertInstanceOf('SoapFault', $e);
$this->checkSoapFault($e, $expectedException->getRawMessage(), 'env:Sender', $expectedException->getParameters());
} else {
$this->assertEquals(HTTPExceptionCodes::HTTP_BAD_REQUEST, $e->getCode());
$exceptionData = $this->processRestExceptionResult($e);
$expectedExceptionData = ['message' => '%fieldName is a required field.', 'parameters' => ['fieldName' => Address::FIRSTNAME]];
$this->assertEquals($expectedExceptionData, $exceptionData);
}
}
try {
$this->customerRegistry->retrieveByEmail($customerDataArray[Customer::EMAIL], $customerDataArray[Customer::WEBSITE_ID]);
$this->fail('An expected NoSuchEntityException was not thrown.');
} catch (NoSuchEntityException $e) {
$exception = NoSuchEntityException::doubleField('email', $customerDataArray[Customer::EMAIL], 'websiteId', $customerDataArray[Customer::WEBSITE_ID]);
$this->assertEquals($exception->getMessage(), $e->getMessage(), 'Exception message does not match expected message.');
}
}