本文整理汇总了PHP中Magento\Framework\Api\ExtensibleDataObjectConverter类的典型用法代码示例。如果您正苦于以下问题:PHP ExtensibleDataObjectConverter类的具体用法?PHP ExtensibleDataObjectConverter怎么用?PHP ExtensibleDataObjectConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExtensibleDataObjectConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function setUp()
{
$this->addressRepositoryMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AddressRepositoryInterface', ['get'], '', false);
$this->accountManagementMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AccountManagementInterface', [], '', false);
$this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
$this->checkoutHelperMock = $this->getMock('Magento\\Checkout\\Helper\\Data', [], [], '', false);
$this->customerUrlMock = $this->getMock('Magento\\Customer\\Model\\Url', [], [], '', false);
$this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
$this->checkoutSessionMock = $this->getMock('Magento\\Checkout\\Model\\Session', ['getLastOrderId', 'getQuote', 'setStepData', 'getStepData'], [], '', false);
$this->customerSessionMock = $this->getMock('Magento\\Customer\\Model\\Session', ['getCustomerDataObject', 'isLoggedIn'], [], '', false);
$this->storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
$this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
$this->addressFactoryMock = $this->getMock('Magento\\Customer\\Model\\AddressFactory', [], [], '', false);
$this->formFactoryMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\FormFactory', [], [], '', false);
$this->customerFactoryMock = $this->getMock('Magento\\Customer\\Model\\CustomerFactory', [], [], '', false);
$this->quoteManagementMock = $this->getMock('Magento\\Quote\\Model\\QuoteManagement', [], [], '', false);
$this->orderFactoryMock = $this->getMock('Magento\\Sales\\Model\\OrderFactory', ['create'], [], '', false);
$this->copyMock = $this->getMock('Magento\\Framework\\Object\\Copy', [], [], '', false);
$this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface');
$this->customerFormFactoryMock = $this->getMock('Magento\\Customer\\Model\\FormFactory', ['create'], [], '', false);
$this->customerDataFactoryMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory', [], [], '', false);
$this->randomMock = $this->getMock('Magento\\Framework\\Math\\Random');
$this->encryptorMock = $this->getMock('Magento\\Framework\\Encryption\\EncryptorInterface');
$this->customerRepositoryMock = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\CustomerRepositoryInterface', [], '', false);
$orderSenderMock = $this->getMock('\\Magento\\Sales\\Model\\Order\\Email\\Sender\\OrderSender', [], [], '', false);
$this->quoteRepositoryMock = $this->getMock('Magento\\Quote\\Model\\QuoteRepository', [], [], '', false);
$this->extensibleDataObjectConverterMock = $this->getMockBuilder('Magento\\Framework\\Api\\ExtensibleDataObjectConverter')->setMethods(['toFlatArray'])->disableOriginalConstructor()->getMock();
$this->extensibleDataObjectConverterMock->expects($this->any())->method('toFlatArray')->will($this->returnValue([]));
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->onepage = $this->objectManagerHelper->getObject('Magento\\Checkout\\Model\\Type\\Onepage', ['eventManager' => $this->eventManagerMock, 'helper' => $this->checkoutHelperMock, 'customerUrl' => $this->customerUrlMock, 'logger' => $this->loggerMock, 'checkoutSession' => $this->checkoutSessionMock, 'customerSession' => $this->customerSessionMock, 'storeManager' => $this->storeManagerMock, 'request' => $this->requestMock, 'customrAddrFactory' => $this->addressFactoryMock, 'customerFormFactory' => $this->customerFormFactoryMock, 'customerFactory' => $this->customerFactoryMock, 'orderFactory' => $this->orderFactoryMock, 'objectCopyService' => $this->copyMock, 'messageManager' => $this->messageManagerMock, 'formFactory' => $this->formFactoryMock, 'customerDataFactory' => $this->customerDataFactoryMock, 'mathRandom' => $this->randomMock, 'encryptor' => $this->encryptorMock, 'addressRepository' => $this->addressRepositoryMock, 'accountManagement' => $this->accountManagementMock, 'orderSenderMock' => $orderSenderMock, 'customerRepository' => $this->customerRepositoryMock, 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverterMock, 'quoteRepository' => $this->quoteRepositoryMock, 'quoteManagement' => $this->quoteManagementMock]);
}
示例2: processDataObject
/**
* Convert data object to array and process available custom attributes
*
* @param array $dataObjectArray
* @return array
*/
protected function processDataObject($dataObjectArray)
{
if (isset($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) {
$dataObjectArray = ExtensibleDataObjectConverter::convertCustomAttributesToSequentialArray($dataObjectArray);
}
//Check for nested custom_attributes
foreach ($dataObjectArray as $key => $value) {
if (is_array($value)) {
$dataObjectArray[$key] = $this->processDataObject($value);
}
}
return $dataObjectArray;
}
示例3: convertKeysToCamelCase
/**
* Convert keys to camelCase
*
* @param array $dataArray
* @return \stdClass
*/
public function convertKeysToCamelCase(array $dataArray)
{
$response = [];
if (isset($dataArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) {
$dataArray = ExtensibleDataObjectConverter::convertCustomAttributesToSequentialArray($dataArray);
}
foreach ($dataArray as $fieldName => $fieldValue) {
if (is_array($fieldValue) && !$this->_isSimpleSequentialArray($fieldValue)) {
$fieldValue = $this->convertKeysToCamelCase($fieldValue);
}
$fieldName = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $fieldName))));
$response[$fieldName] = $fieldValue;
}
return $response;
}
示例4: testGetCustomerAttributeMetadata
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
*/
public function testGetCustomerAttributeMetadata()
{
// Expect these attributes to exist but do not check the value
$expectAttrsWOutVals = ['created_at', 'updated_at'];
// Expect these attributes to exist and check the value - values come from _files/customer.php
$expectAttrsWithVals = ['id' => 1, 'website_id' => 1, 'store_id' => 1, 'group_id' => 1, 'prefix' => 'Mr.', 'firstname' => 'John', 'middlename' => 'A', 'lastname' => 'Smith', 'suffix' => 'Esq.', 'email' => 'customer@example.com', 'default_billing' => '1', 'default_shipping' => '1', 'disable_auto_group_change' => 0, 'taxvat' => '12', 'gender' => 0];
$customer = $this->customerRepository->getById(1);
$this->assertNotNull($customer);
$attributes = $this->_extensibleDataObjectConverter->toFlatArray($customer, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$this->assertNotEmpty($attributes);
foreach ($attributes as $attributeCode => $attributeValue) {
$this->assertNotNull($attributeCode);
$this->assertNotNull($attributeValue);
$attributeMetadata = $this->_service->getAttributeMetadata($attributeCode);
$attrMetadataCode = $attributeMetadata->getAttributeCode();
$this->assertSame($attributeCode, $attrMetadataCode);
if (($key = array_search($attrMetadataCode, $expectAttrsWOutVals)) !== false) {
unset($expectAttrsWOutVals[$key]);
} else {
$this->assertArrayHasKey($attrMetadataCode, $expectAttrsWithVals);
$this->assertSame($expectAttrsWithVals[$attrMetadataCode], $attributeValue, "Failed for {$attrMetadataCode}");
unset($expectAttrsWithVals[$attrMetadataCode]);
}
}
$this->assertEmpty($expectAttrsWOutVals);
$this->assertEmpty($expectAttrsWithVals);
}
示例5: testGetProductWeeeAttributes
public function testGetProductWeeeAttributes()
{
/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
$customerRepository = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\CustomerRepositoryInterface');
$customerMetadataService = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\CustomerMetadataInterface');
$customerFactory = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory', ['metadataService' => $customerMetadataService]);
$dataObjectHelper = Bootstrap::getObjectManager()->create('Magento\\Framework\\Api\\DataObjectHelper');
$expected = $this->_extensibleDataObjectConverter->toFlatArray($customerRepository->getById(1), [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$customerDataSet = $customerFactory->create();
$dataObjectHelper->populateWithArray($customerDataSet, $expected, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$fixtureGroupCode = 'custom_group';
$fixtureTaxClassId = 3;
/** @var \Magento\Customer\Model\Group $group */
$group = Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Group');
$fixtureGroupId = $group->load($fixtureGroupCode, 'customer_group_code')->getId();
/** @var \Magento\Quote\Model\Quote $quote */
$quote = Bootstrap::getObjectManager()->create('Magento\\Quote\\Model\\Quote');
$quote->setCustomerGroupId($fixtureGroupId);
$quote->setCustomerTaxClassId($fixtureTaxClassId);
$quote->setCustomer($customerDataSet);
$shipping = new \Magento\Framework\DataObject(['quote' => $quote]);
$productRepository = Bootstrap::getObjectManager()->create('Magento\\Catalog\\Api\\ProductRepositoryInterface');
$product = $productRepository->get('simple-with-ftp');
$amount = $this->_model->getProductWeeeAttributes($product, $shipping, null, null, true);
$this->assertTrue(is_array($amount));
$this->assertArrayHasKey(0, $amount);
$this->assertEquals(12.7, $amount[0]->getAmount());
}
示例6: testGetProductWeeeAttributes
public function testGetProductWeeeAttributes()
{
/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
$customerRepository = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\CustomerRepositoryInterface');
$customerMetadataService = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\CustomerMetadataInterface');
$customerFactory = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory', ['metadataService' => $customerMetadataService]);
$dataObjectHelper = Bootstrap::getObjectManager()->create('Magento\\Framework\\Api\\DataObjectHelper');
$expected = $this->_extensibleDataObjectConverter->toFlatArray($customerRepository->getById(1), [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$customerDataSet = $customerFactory->create();
$dataObjectHelper->populateWithArray($customerDataSet, $expected, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$fixtureGroupCode = 'custom_group';
$fixtureTaxClassId = 3;
/** @var \Magento\Customer\Model\Group $group */
$group = Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Group');
$fixtureGroupId = $group->load($fixtureGroupCode, 'customer_group_code')->getId();
/** @var \Magento\Quote\Model\Quote $quote */
$quote = Bootstrap::getObjectManager()->create('Magento\\Quote\\Model\\Quote');
$quote->setCustomerGroupId($fixtureGroupId);
$quote->setCustomerTaxClassId($fixtureTaxClassId);
$quote->setCustomer($customerDataSet);
$shipping = new \Magento\Framework\Object(['quote' => $quote]);
$product = Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product');
$product->load(1);
$weeeTax = Bootstrap::getObjectManager()->create('Magento\\Weee\\Model\\Tax');
$weeeTaxData = ['website_id' => '1', 'entity_id' => '1', 'country' => 'US', 'value' => '12.4', 'state' => '0', 'attribute_id' => '73', 'entity_type_id' => '0'];
$weeeTax->setData($weeeTaxData);
$weeeTax->save();
$amount = $this->_model->getProductWeeeAttributes($product, $shipping);
$this->assertEquals('12.4000', $amount[0]->getAmount());
}
示例7: testToNestedArrayCustom
/**
* Test toNestedArray() method with custom attributes and with skipped custom attribute.
*/
public function testToNestedArrayCustom()
{
$dataArray = ['attribute_key' => 'attribute_value', AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY => [[AttributeValue::ATTRIBUTE_CODE => 'custom_attribute_code', AttributeValue::VALUE => 'custom_attribute_value'], [AttributeValue::ATTRIBUTE_CODE => 'custom_attribute_code_multi', AttributeValue::VALUE => ['custom_attribute_value_multi_1', 'custom_attribute_value_multi_2']], [AttributeValue::ATTRIBUTE_CODE => 'custom_attribute_code_skip', AttributeValue::VALUE => 'custom_attribute_value_skip']]];
$resultArray = ['attribute_key' => 'attribute_value', 'custom_attribute_code' => 'custom_attribute_value', 'custom_attribute_code_multi' => ['custom_attribute_value_multi_1', 'custom_attribute_value_multi_2']];
$this->processor->expects($this->any())->method('buildOutputDataArray')->with($this->dataObject)->willReturn($dataArray);
$this->assertEquals($resultArray, $this->converter->toNestedArray($this->dataObject, ['custom_attribute_code_skip']));
}
示例8: testToFlatArray
public function testToFlatArray()
{
$expectedResultWithoutStreet = ['id' => 1, 'default_shipping' => false, 'default_billing' => true, 'firstname' => 'John', 'lastname' => 'Doe', 'city' => 'Austin', 'country_id' => 'US', 'region_id' => 1, 'region' => 'Texas', 'region_code' => 'TX'];
$expectedResultWithStreet = array_merge($expectedResultWithoutStreet, ['street' => ['7700 W Parmer Ln', 'Austin, TX']]);
$this->extensibleObjectConverter->expects($this->once())->method('toFlatArray')->willReturn($expectedResultWithoutStreet);
$addressData = $this->createAddressMock();
$result = $this->addressMapper->toFlatArray($addressData);
$this->assertEquals($expectedResultWithStreet, $result);
}
示例9: _prepareForm
/**
* Prepare the form.
*
* @return $this
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getUrl('customer/*/save'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
$customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
if ($customerId) {
$form->addField('id', 'hidden', ['name' => 'customer_id']);
$customer = $this->_customerRepository->getById($customerId);
$form->setValues($this->_extensibleDataObjectConverter->toFlatArray($customer, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface'))->addValues(['customer_id' => $customerId]);
}
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例10: toFlatArray
/**
* Convert address data object to a flat array
*
* @param AddressInterface $addressDataObject
* @return array
* TODO:: Add concrete type of AddressInterface for $addressDataObject parameter once
* all references have been refactored.
*/
public function toFlatArray($addressDataObject)
{
$flatAddressArray = $this->extensibleDataObjectConverter->toFlatArray($addressDataObject, [], '\\Magento\\Customer\\Api\\Data\\AddressInterface');
//preserve street
$street = $addressDataObject->getStreet();
if (!empty($street) && is_array($street)) {
// Unset flat street data
$streetKeys = array_keys($street);
foreach ($streetKeys as $key) {
unset($flatAddressArray[$key]);
}
//Restore street as an array
$flatAddressArray[AddressInterface::STREET] = $street;
}
return $flatAddressArray;
}
示例11: save
/**
* {@inheritdoc}
*/
public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveOptions = false)
{
if ($saveOptions) {
$productOptions = $product->getProductOptions();
}
$groupPrices = $product->getData('group_price');
$tierPrices = $product->getData('tier_price');
$productId = $this->resourceModel->getIdBySku($product->getSku());
$productDataArray = $this->extensibleDataObjectConverter->toNestedArray($product, [], 'Magento\\Catalog\\Api\\Data\\ProductInterface');
$product = $this->initializeProductData($productDataArray, empty($productId));
$validationResult = $this->resourceModel->validate($product);
if (true !== $validationResult) {
throw new \Magento\Framework\Exception\CouldNotSaveException(__('Invalid product data: %1', implode(',', $validationResult)));
}
try {
if ($saveOptions) {
$product->setProductOptions($productOptions);
$product->setCanSaveCustomOptions(true);
}
$product->setData('group_price', $groupPrices);
$product->setData('tier_price', $tierPrices);
$this->resourceModel->save($product);
} catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) {
throw \Magento\Framework\Exception\InputException::invalidFieldValue($exception->getAttributeCode(), $product->getData($exception->getAttributeCode()), $exception);
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\CouldNotSaveException(__('Unable to save product'));
}
unset($this->instances[$product->getSku()]);
unset($this->instancesById[$product->getId()]);
return $product;
}
示例12: testCreateNonexistingCustomer
/**
* @magentoAppArea frontend
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDbIsolation enabled
*/
public function testCreateNonexistingCustomer()
{
$existingCustId = 1;
$existingCustomer = $this->customerRepository->getById($existingCustId);
$email = 'savecustomer@example.com';
$firstName = 'Firstsave';
$lastName = 'Lastsave';
$customerData = array_merge($existingCustomer->__toArray(), ['email' => $email, 'firstname' => $firstName, 'lastname' => $lastName, 'id' => null]);
$customerEntity = $this->customerFactory->create();
$this->dataObjectHelper->populateWithArray($customerEntity, $customerData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$customerAfter = $this->accountManagement->createAccount($customerEntity, 'aPassword');
$this->assertGreaterThan(0, $customerAfter->getId());
$this->assertEquals($email, $customerAfter->getEmail());
$this->assertEquals($firstName, $customerAfter->getFirstname());
$this->assertEquals($lastName, $customerAfter->getLastname());
$this->accountManagement->authenticate($customerAfter->getEmail(), 'aPassword');
$attributesBefore = $this->extensibleDataObjectConverter->toFlatArray($existingCustomer, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$attributesAfter = $this->extensibleDataObjectConverter->toFlatArray($customerAfter, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
// ignore 'updated_at'
unset($attributesBefore['updated_at']);
unset($attributesAfter['updated_at']);
$inBeforeOnly = array_diff_assoc($attributesBefore, $attributesAfter);
$inAfterOnly = array_diff_assoc($attributesAfter, $attributesBefore);
$expectedInBefore = ['email', 'firstname', 'id', 'lastname'];
sort($expectedInBefore);
$actualInBeforeOnly = array_keys($inBeforeOnly);
sort($actualInBeforeOnly);
$this->assertEquals($expectedInBefore, $actualInBeforeOnly);
$expectedInAfter = ['created_in', 'email', 'firstname', 'id', 'lastname'];
sort($expectedInAfter);
$actualInAfterOnly = array_keys($inAfterOnly);
sort($actualInAfterOnly);
$this->assertEquals($expectedInAfter, $actualInAfterOnly);
}
示例13: _getCustomerForm
/**
* Initialize customer form
*
* @return \Magento\Customer\Model\Metadata\Form $customerForm
*/
protected function _getCustomerForm()
{
if ($this->_customerForm === null) {
$this->_customerForm = $this->_customerFormFactory->create('customer', 'adminhtml_customer', $this->_extensibleDataObjectConverter->toFlatArray($this->_getCustomerDataObject()));
}
return $this->_customerForm;
}
示例14: save
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveOptions = false)
{
if ($saveOptions) {
$productOptions = $product->getProductOptions();
}
$isDeleteOptions = $product->getIsDeleteOptions();
$tierPrices = $product->getData('tier_price');
$productId = $this->resourceModel->getIdBySku($product->getSku());
$ignoreLinksFlag = $product->getData('ignore_links_flag');
$productDataArray = $this->extensibleDataObjectConverter->toNestedArray($product, [], 'Magento\\Catalog\\Api\\Data\\ProductInterface');
$productLinks = null;
if (!$ignoreLinksFlag && $ignoreLinksFlag !== null) {
$productLinks = $product->getProductLinks();
}
$productDataArray['store_id'] = (int) $this->storeManager->getStore()->getId();
$product = $this->initializeProductData($productDataArray, empty($productId));
if (isset($productDataArray['options'])) {
if (!empty($productDataArray['options']) || $isDeleteOptions) {
$this->processOptions($product, $productDataArray['options']);
$product->setCanSaveCustomOptions(true);
}
}
$this->processLinks($product, $productLinks);
if (isset($productDataArray['media_gallery_entries'])) {
$this->processMediaGallery($product, $productDataArray['media_gallery_entries']);
}
$validationResult = $this->resourceModel->validate($product);
if (true !== $validationResult) {
throw new \Magento\Framework\Exception\CouldNotSaveException(__('Invalid product data: %1', implode(',', $validationResult)));
}
try {
if ($saveOptions) {
$product->setProductOptions($productOptions);
$product->setCanSaveCustomOptions(true);
}
if ($tierPrices !== null) {
$product->setData('tier_price', $tierPrices);
}
$this->resourceModel->save($product);
} catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) {
throw \Magento\Framework\Exception\InputException::invalidFieldValue($exception->getAttributeCode(), $product->getData($exception->getAttributeCode()), $exception);
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\CouldNotSaveException(__('Unable to save product'));
}
unset($this->instances[$product->getSku()]);
unset($this->instancesById[$product->getId()]);
return $this->get($product->getSku());
}
示例15: testExecuteWithException
public function testExecuteWithException()
{
$this->request->expects($this->once())->method('getPost')->willReturn(null);
$this->form->expects($this->once())->method('setInvisibleIgnored');
$this->form->expects($this->atLeastOnce())->method('extractData')->willReturn([]);
$this->form->expects($this->never())->method('validateData');
$this->extensibleDataObjectConverter->expects($this->once())->method('toFlatArray')->willReturn([]);
$validationResult = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\ValidationResultsInterface', [], '', false, true, true);
$error = $this->getMock('Magento\\Framework\\Message\\Error', [], [], '', false);
$error->expects($this->once())->method('getText')->willReturn('Error text');
$exception = $this->getMock('Magento\\Framework\\Validator\\Exception', [], [], '', false);
$exception->expects($this->once())->method('getMessages')->willReturn([$error]);
$validationResult->expects($this->once())->method('getMessages')->willThrowException($exception);
$this->customerAccountManagement->expects($this->once())->method('validate')->willReturn($validationResult);
$this->controller->execute();
}