/**
  * Execute per test initialization.
  */
 public function setUp()
 {
     $this->_markTestAsRestOnly();
     $this->customerRegistry = Bootstrap::getObjectManager()->get('Magento\\Customer\\Model\\CustomerRegistry');
     $this->customerRepository = Bootstrap::getObjectManager()->get('Magento\\Customer\\Api\\CustomerRepositoryInterface', ['customerRegistry' => $this->customerRegistry]);
     $this->customerAccountManagement = Bootstrap::getObjectManager()->get('Magento\\Customer\\Api\\AccountManagementInterface');
     $this->customerHelper = new CustomerHelper();
     $this->customerData = $this->customerHelper->createSampleCustomer();
     // get token
     $this->resetTokenForCustomerSampleData();
     $this->dataObjectProcessor = Bootstrap::getObjectManager()->create('Magento\\Framework\\Reflection\\DataObjectProcessor');
 }
 /**
  * Create customer with image attribute
  *
  * @param array $imageData
  * @return array Customer data as array
  */
 protected function createCustomerWithImageAttribute($imageData)
 {
     $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 . 'CreateAccount']];
     $customerData = $this->customerHelper->createSampleCustomerDataObject();
     $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray($customerData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $customerDataArray['custom_attributes'][] = ['attribute_code' => 'customer_image', 'value' => $imageData];
     $requestData = ['customer' => $customerDataArray, 'password' => \Magento\TestFramework\Helper\Customer::PASSWORD];
     $customerData = $this->_webApiCall($serviceInfo, $requestData);
     return $customerData;
 }
示例#3
0
 /**
  * @return array
  */
 private function generateCustomerData()
 {
     $customer = $this->customerHelper->createSampleCustomerDataObject();
     /** @var \Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterface $extensionAttribute */
     $extensionAttribute = $this->objectManager->create(\Magento\TestModuleDefaultHydrator\Api\Data\ExtensionAttributeInterface::class);
     $extensionAttribute->setValue('extension attribute value');
     /** @var \Magento\Customer\Api\Data\CustomerExtensionInterface $customerExtension */
     $customerExtension = $this->objectManager->create(\Magento\Customer\Api\Data\CustomerExtension::class);
     $customerExtension->setExtensionAttribute($extensionAttribute);
     $customer->setExtensionAttributes($customerExtension);
     $customer->setCustomAttribute('custom_attribute1', 'custom attribute value');
     $customerData = $this->dataObjectProcessor->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
     return $customerData;
 }
 public function testUnsubscribeCustomer()
 {
     //Creating customer and subscribe
     $customerData = $this->customerHelper->createSampleCustomer(["extension_attributes" => ["is_subscribed" => true]]);
     $this->assertNotNull($customerData['id']);
     $this->subscriber->loadByCustomerId($customerData['id']);
     $subscriptionId = $this->subscriber->getId();
     $this->assertNotNull($subscriptionId);
     $this->assertEquals($customerData['id'], $this->subscriber->getCustomerId());
     //Manage customer in order to unsubscribe
     $this->customerHelper->updateSampleCustomer(array_merge($customerData, ["extension_attributes" => ["is_subscribed" => false]]), $customerData["id"]);
     $this->initSubscriber();
     $this->subscriber->loadByCustomerId($customerData['id']);
     $this->assertEquals(Subscriber::STATUS_UNSUBSCRIBED, $this->subscriber->getStatus());
 }
 /**
  * @return array|bool|float|int|string
  */
 protected function _createCustomer()
 {
     $customerData = $this->customerHelper->createSampleCustomer();
     $this->currentCustomerId[] = $customerData['id'];
     return $customerData;
 }
 protected function setUp()
 {
     $this->_markTestAsRestOnly('Partial response functionality available in REST mode only.');
     $this->customerHelper = Bootstrap::getObjectManager()->get('Magento\\TestFramework\\Helper\\Customer');
     $this->customerData = $this->customerHelper->createSampleCustomer();
 }