objectManager = Bootstrap::getObjectManager(); $this->orderAddressRenderer = $this->objectManager->get(OrderAddressRenderer::class); $this->configResourceModel = $this->objectManager->get(ConfigResourceModel::class); $this->config = $this->objectManager->get(Config::class); } /** * @magentoDataFixture Magento/Sales/_files/order_fixture_store.php * @magentoDbIsolation disabled * @magentoAppIsolation enabled */ public function testFormat() { $addressTemplates = [ 'text' => 'text_customized', 'oneline' => 'oneline_customized', 'html' => 'html_customized', 'pdf' => 'pdf_customized' ]; /** @var Store $store */ $store = $this->objectManager->create(Store::class); $storeId = $store->load('fixturestore')->getStoreId(); $this->configResourceModel->saveConfig( 'customer/address_templates/text', $addressTemplates['text'], 'stores', $storeId ); $this->configResourceModel->saveConfig( 'customer/address_templates/oneline', $addressTemplates['oneline'], 'stores', $storeId ); $this->configResourceModel->saveConfig( 'customer/address_templates/html', $addressTemplates['html'], 'stores', $storeId ); $this->configResourceModel->saveConfig( 'customer/address_templates/pdf', $addressTemplates['pdf'], 'stores', $storeId ); $this->config->clean(); /** @var Order $order */ $order = $this->objectManager->create(Order::class) ->loadByIncrementId('100000004'); /** @var OrderAddress $address */ $address = $order->getBillingAddress(); $this->assertEquals($addressTemplates['text'], $this->orderAddressRenderer->format($address, 'text')); $this->assertEquals($addressTemplates['oneline'], $this->orderAddressRenderer->format($address, 'oneline')); $this->assertEquals($addressTemplates['html'], $this->orderAddressRenderer->format($address, 'html')); $this->assertEquals($addressTemplates['pdf'], $this->orderAddressRenderer->format($address, 'pdf')); } }