|
6 | 6 | namespace Magento\Shipping\Block\Adminhtml\Order;
|
7 | 7 |
|
8 | 8 | use Magento\Backend\Block\Template;
|
| 9 | +use Magento\Framework\Api\SearchCriteria; |
| 10 | +use Magento\Framework\Api\SearchCriteriaBuilder; |
9 | 11 | use Magento\Framework\ObjectManagerInterface;
|
10 | 12 | use Magento\Framework\Registry;
|
11 |
| -use Magento\Sales\Api\Data\OrderInterfaceFactory; |
| 13 | +use Magento\Sales\Api\Data\OrderInterface; |
12 | 14 | use Magento\Sales\Api\Data\ShipmentTrackInterface;
|
13 | 15 | use Magento\TestFramework\Helper\Bootstrap;
|
14 | 16 | use PHPUnit\Framework\TestCase;
|
| 17 | +use Magento\Sales\Api\OrderRepositoryInterface; |
15 | 18 |
|
16 | 19 | /**
|
17 | 20 | * Class verifies packaging popup.
|
|
20 | 23 | */
|
21 | 24 | class AddToPackageTest extends TestCase
|
22 | 25 | {
|
| 26 | + /** |
| 27 | + * @var OrderRepositoryInterface |
| 28 | + */ |
| 29 | + private $orderRepository; |
| 30 | + |
23 | 31 | /** @var ObjectManagerInterface */
|
24 | 32 | private $objectManager;
|
25 | 33 |
|
26 | 34 | /** @var Registry */
|
27 | 35 | private $registry;
|
28 |
| - /** |
29 |
| - * @var OrderInterfaceFactory|mixed |
30 |
| - */ |
31 |
| - private $orderFactory; |
32 | 36 |
|
33 | 37 | protected function setUp(): void
|
34 | 38 | {
|
35 | 39 | $this->objectManager = Bootstrap::getObjectManager();
|
36 | 40 | $this->registry = $this->objectManager->get(Registry::class);
|
37 |
| - $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); |
| 41 | + $this->orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Loads order entity by provided order increment ID. |
| 46 | + * |
| 47 | + * @param string $incrementId |
| 48 | + * @return OrderInterface |
| 49 | + */ |
| 50 | + private function getOrderByIncrementId(string $incrementId) : OrderInterface |
| 51 | + { |
| 52 | + /** @var SearchCriteria $searchCriteria */ |
| 53 | + $searchCriteria = $this->objectManager->get(SearchCriteriaBuilder::class) |
| 54 | + ->addFilter('increment_id', $incrementId) |
| 55 | + ->create(); |
| 56 | + |
| 57 | + $items = $this->orderRepository->getList($searchCriteria) |
| 58 | + ->getItems(); |
| 59 | + |
| 60 | + return array_pop($items); |
38 | 61 | }
|
39 | 62 |
|
40 | 63 | /**
|
41 | 64 | * Test that Packaging popup renders
|
42 | 65 | *
|
43 |
| - * @magentoDataFixture Magento/GraphQl/Sales/_files/customer_order_with_ups_shipping.php |
| 66 | + * @magentoDataFixture Magento/Shipping/_files/shipping_with_carrier_data.php |
44 | 67 | */
|
45 | 68 | public function testGetCommentsHtml()
|
46 | 69 | {
|
47 | 70 | /** @var Template $block */
|
48 | 71 | $block = $this->objectManager->get(Packaging::class);
|
49 | 72 |
|
50 |
| - $order = $this->orderFactory->create()->loadByIncrementId('100000001'); |
| 73 | + $order = $this->getOrderByIncrementId('100000001'); |
51 | 74 |
|
52 | 75 | /** @var ShipmentTrackInterface $track */
|
53 | 76 | $shipment = $order->getShipmentsCollection()->getFirstItem();
|
|
0 commit comments