/** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Core/_files/second_third_store.php * @magentoConfigFixture current_store customer/account_share/scope 0 */ public function testToHtmlEmptyGlobalShareAndSessionData() { $this->registry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); $customer = $this->customerAccountService->getCustomer(1); $this->backendSession->setCustomerData(array('account' => $customer->__toArray())); $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\View\\Accordion'); $html = $block->toHtml(); $this->assertContains('Wishlist - 0 item(s)', $html); $this->assertContains('Shopping Cart of Main Website - 0 item(s)', $html); $this->assertContains('Shopping Cart of Second Website - 0 item(s)', $html); $this->assertContains('Shopping Cart of Third Website - 0 item(s)', $html); }
/** * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testNewCustomer() { $customerBuilder = $this->objectManager->get('\\Magento\\Customer\\Service\\V1\\Data\\CustomerBuilder'); $this->backendSession->setCustomerData(array('customer_id' => 0, 'account' => $customerBuilder->create()->__toArray())); $result = $this->accountBlock->initForm()->toHtml(); // Contains send email controls $this->assertContains('<input id="_accountsendemail"', $result); $this->assertContains('<select id="_accountsendemail_store_id"', $result); }
/** * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testNewCustomer() { /** @var \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory */ $customerFactory = $this->objectManager->get('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory'); $customerData = $this->dataObjectProcessor->buildOutputDataArray($customerFactory->create(), '\\Magento\\Customer\\Api\\Data\\CustomerInterface'); $this->backendSession->setCustomerData(['customer_id' => 0, 'account' => $customerData]); $result = $this->accountBlock->initForm()->toHtml(); // Contains send email controls $this->assertContains('<input id="_accountsendemail"', $result); $this->assertContains('<select id="_accountsendemail_store_id"', $result); }
/** * Put existing customer data into the backend session */ protected function setupExistingCustomerData() { /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */ $customer = $this->_customerRepository->getById(1); $this->_customerData = ['customer_id' => $customer->getId(), 'account' => $this->customerMapper->toFlatArray($customer)]; $this->_customerData['account']['id'] = $customer->getId(); /** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */ $addresses = $customer->getAddresses(); foreach ($addresses as $addressData) { $this->_customerData['address'][$addressData->getId()] = $this->addressMapper->toFlatArray($addressData); $this->_customerData['address'][$addressData->getId()]['id'] = $addressData->getId(); } $this->_backendSession->setCustomerData($this->_customerData); }
/** * Put existing customer data into the backend session */ protected function setupExistingCustomerData() { /** @var Customer $customer */ $customer = $this->_customerAccountService->getCustomer(1); $this->_customerData = array('customer_id' => $customer->getId(), 'account' => \Magento\Framework\Service\ExtensibleDataObjectConverter::toFlatArray($customer)); $this->_customerData['account']['id'] = $customer->getId(); /** @var Address[] $addresses */ $addresses = $this->_addressService->getAddresses(1); foreach ($addresses as $addressData) { $this->_customerData['address'][$addressData->getId()] = AddressConverter::toFlatArray($addressData); $this->_customerData['address'][$addressData->getId()]['id'] = $addressData->getId(); } $this->_backendSession->setCustomerData($this->_customerData); }