public function testGetHtmlNoCustomer() { $data = ['account' => []]; $this->_context->getBackendSession()->setCustomerData($data); $this->_block = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\Carts', '', ['context' => $this->_context]); $html = $this->_block->toHtml(); $this->assertContains("<div id=\"customer_cart_grid\"", $html); $this->assertRegExp('/<div class=".*admin__data-grid-toolbar"/', $html); $this->assertContains("customer_cart_gridJsObject = new varienGrid('customer_cart_grid',", $html); $this->assertContains("backend/customer/cart_product_composite_cart/configure/key/", $html); }
public function testGetHtmlNoCustomer() { $data = array('account' => array()); $this->_context->getBackendSession()->setCustomerData($data); $this->_block = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\Carts', '', array('context' => $this->_context)); $html = $this->_block->toHtml(); $this->assertContains("<div id=\"customer_cart_grid0\">", $html); $this->assertContains("<div class=\"grid-actions\">", $html); $this->assertContains("customer_cart_grid0JsObject = new varienGrid('customer_cart_grid0',", $html); $this->assertContains("backend/customer/cart_product_composite_cart/configure/website_id/0/key/", $html); }
/** * @return \Magento\Customer\Api\Data\CustomerInterface */ private function _loadCustomer() { $customer = $this->_customerRepository->getById(1); $data = ['account' => $this->_dataObjectProcessor->buildOutputDataArray($customer, 'Magento\\Customer\\Api\\Data\\CustomerInterface')]; $this->_context->getBackendSession()->setCustomerData($data); $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); return $customer; }
/** * @return Customer */ private function _loadCustomer() { $customer = $this->_customerAccountService->getCustomer(1); $data = array('account' => $customer->__toArray()); $this->_context->getBackendSession()->setCustomerData($data); $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); return $customer; }
/** * @param \Magento\Backend\Block\Template\Context $context * @param array $data */ public function __construct(\Magento\Backend\Block\Template\Context $context, array $data = array()) { $this->_localeDate = $context->getLocaleDate(); $this->_authorization = $context->getAuthorization(); $this->mathRandom = $context->getMathRandom(); $this->_backendSession = $context->getBackendSession(); $this->formKey = $context->getFormKey(); $this->nameBuilder = $context->getNameBuilder(); parent::__construct($context, $data); }
/** * No data fixture nor is there a customer Id set in the registry. */ public function testToHtmlNoCustomerId() { $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); $customerData['account'] = array(Customer::FIRSTNAME => 'John', Customer::LASTNAME => 'Doe', Customer::EMAIL => '*****@*****.**', Customer::GROUP_ID => 1, Customer::WEBSITE_ID => 1); $customerData['address'] = array(); $this->context->getBackendSession()->setCustomerData($customerData); $html = $this->block->toHtml(); $this->assertNotContains('name="cart" title="Shopping Cart"', $html); $this->assertNotContains('name="wishlist" title="Wishlist"', $html); $this->assertStringMatchesFormat('%a name="account[firstname]" %s value="John" %a', $html); $this->assertStringMatchesFormat('%a name="account[lastname]" %s value="Doe" %a', $html); $this->assertStringMatchesFormat('%a name="account[email]" %s value="*****@*****.**" %a', $html); }
/** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param array $data */ public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, array $data = []) { $this->_backendHelper = $backendHelper; $this->_backendSession = $context->getBackendSession(); parent::__construct($context, $data); }