|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Sales\Block\Adminhtml\Order\View; |
| 9 | + |
| 10 | +use Magento\Config\Model\Config\Factory; |
| 11 | +use Magento\Framework\ObjectManagerInterface; |
| 12 | +use Magento\Sales\Model\Order; |
| 13 | +use Magento\Store\Model\StoreManagerInterface; |
| 14 | +use Magento\TestFramework\Helper\Bootstrap; |
| 15 | +use Magento\Sales\Model\Order\Address\Renderer as OrderAddressRenderer; |
| 16 | +use PHPUnit\Framework\TestCase; |
| 17 | + |
| 18 | +/** |
| 19 | + * Test class for \Magento\Sales\Block\Adminhtml\Order\View\AddressInfo |
| 20 | + */ |
| 21 | +class AddressInfoTest extends TestCase |
| 22 | +{ |
| 23 | + /** |
| 24 | + * @var ObjectManagerInterface |
| 25 | + */ |
| 26 | + private $objectManager; |
| 27 | + |
| 28 | + /** |
| 29 | + * @var OrderAddressRenderer |
| 30 | + */ |
| 31 | + private $orderAddressRenderer; |
| 32 | + |
| 33 | + /** |
| 34 | + * Set up |
| 35 | + */ |
| 36 | + protected function setUp(): void |
| 37 | + { |
| 38 | + $this->objectManager = Bootstrap::getObjectManager(); |
| 39 | + $this->orderAddressRenderer = $this->objectManager->get(OrderAddressRenderer::class); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Verify customer address attributes (e.g. Company) are visible on second website order. |
| 44 | + * |
| 45 | + * @magentoDataFixture Magento/Store/_files/second_website_with_store_group_and_store.php |
| 46 | + * @magentoDataFixture Magento/Sales/_files/order_on_second_website.php |
| 47 | + * @magentoAppArea adminhtml |
| 48 | + * @magentoDbIsolation disabled |
| 49 | + * @magentoAppIsolation enabled |
| 50 | + */ |
| 51 | + public function testCompanyAddressAttributeVisibleForOrderOnSecondWebsite() |
| 52 | + { |
| 53 | + $storeManager = $this->objectManager->get(StoreManagerInterface::class); |
| 54 | + $website = $storeManager->getWebsites(false, true)['base']; |
| 55 | + $configData = [ |
| 56 | + 'section' => 'customer', |
| 57 | + 'website' => $website->getId(), |
| 58 | + 'store' => null, |
| 59 | + 'groups' => [ |
| 60 | + 'address' => [ |
| 61 | + 'fields' => [ |
| 62 | + 'company_show' => ['value' => ''], |
| 63 | + ], |
| 64 | + ], |
| 65 | + ], |
| 66 | + ]; |
| 67 | + $configFactory = $this->objectManager->get(Factory::class); |
| 68 | + $config = $configFactory->create(['data' => $configData]); |
| 69 | + $config->save(); |
| 70 | + $orderFixtureStore = $this->objectManager->create(Order::class)->loadByIncrementId('100000001'); |
| 71 | + $address = $orderFixtureStore->getBillingAddress(); |
| 72 | + self::assertStringContainsString('Test Company', $this->orderAddressRenderer->format($address, 'html')); |
| 73 | + } |
| 74 | +} |
0 commit comments