/** * 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'); }
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(); }