38 private $accountManagement;
43 private $customerHelper;
48 private $currentCustomerId;
53 private $dataObjectProcessor;
58 private $imageFactory;
71 \
Magento\Customer\Api\AccountManagementInterface::class
74 $this->customerHelper =
new CustomerHelper();
77 \
Magento\Framework\Reflection\DataObjectProcessor::class
87 if (!empty($this->currentCustomerId)) {
91 'resourcePath' => self::RESOURCE_PATH .
'/' .
$customerId,
106 $this->accountManagement =
null;
118 $image = $this->imageFactory->create()
119 ->setType(
'image/jpeg')
120 ->setName(
'sample.jpeg')
121 ->setBase64EncodedData($imageData);
123 $imageData = $this->dataObjectProcessor->buildOutputDataArray(
125 \
Magento\Framework\Api\Data\ImageContentInterface::class
146 'operation' => self::SERVICE_NAME .
'CreateAccount',
150 $customerData = $this->customerHelper->createSampleCustomerDataObject();
152 $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray(
154 \
Magento\Customer\Api\Data\CustomerInterface::class
156 $customerDataArray[
'custom_attributes'][] = [
157 'attribute_code' =>
'customer_image',
158 'value' => $imageData,
161 'customer' => $customerDataArray,
171 $imageAttributeFound =
false;
172 foreach ($customAttributeArray as $customAttribute) {
178 $this->assertTrue($imageAttributeFound,
'Expected file was not created');
181 if (!$imageAttributeFound) {
182 $this->fail(
'Expected image attribute missing.');
201 $image = $this->imageFactory->create()
202 ->setType(
'image/jpeg')
203 ->setName(
'sample.jpeg')
204 ->setBase64EncodedData(
'INVALID_IMAGE_DATA');
206 $imageData = $this->dataObjectProcessor->buildOutputDataArray(
208 \
Magento\Framework\Api\Data\ImageContentInterface::class
210 $expectedMessage =
'The image content must be valid base64 encoded data.';
213 }
catch (\SoapFault $e) {
214 $this->assertContains(
217 "Exception message does not match" 219 }
catch (\Exception $e) {
221 $this->assertEquals($expectedMessage, $errorObj[
'message']);
222 $this->assertEquals(HTTPExceptionCodes::HTTP_BAD_REQUEST, $e->getCode());
232 $previousCustomerData = $customerDataArray;
236 $image = $this->imageFactory->create()
237 ->setType(
'image/png')
238 ->setName(
'buttons.png')
239 ->setBase64EncodedData($imageData);
240 $imageData = $this->dataObjectProcessor->buildOutputDataArray(
242 \
Magento\Framework\Api\Data\ImageContentInterface::class
246 $customerDataArray[
'custom_attributes'][1] = [
247 'attribute_code' =>
'customer_image',
248 'value' => $imageData,
251 'customer' => $customerDataArray,
257 'resourcePath' => self::RESOURCE_PATH .
"/{$customerDataArray[CustomerInterface::ID]}",
261 'service' =>
'customerCustomerRepositoryV1',
263 'operation' =>
'customerCustomerRepositoryV1Save',
274 $this->assertFalse(file_exists($customerMediaPath . $previousImagePath));
testUpdateCustomerWithImageAttribute()
verifyImageAttribute($customAttributeArray, $expectedFileName)
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testCreateCustomerWithInvalidImageAttribute()
createCustomerWithImageAttribute($imageData)
testCreateCustomerWithImageAttribute()
processRestExceptionResult(\Exception $e)
createCustomerWithDefaultImageAttribute()
static getObjectManager()