|
8 | 8 | namespace Magento\GraphQl\Downloadable;
|
9 | 9 |
|
10 | 10 | use Magento\Integration\Api\CustomerTokenServiceInterface;
|
11 |
| -use Magento\Quote\Api\CartManagementInterface; |
12 |
| -use Magento\Quote\Model\ResourceModel\Quote as QuoteResource; |
13 | 11 | use Magento\TestFramework\Helper\Bootstrap;
|
14 | 12 | use Magento\TestFramework\TestCase\GraphQlAbstract;
|
15 |
| -use Magento\Quote\Model\QuoteFactory; |
16 | 13 |
|
17 | 14 | /**
|
18 |
| - * Test retrieving of customer download products |
| 15 | + * Test retrieving of customer downloadable products. |
19 | 16 | */
|
20 | 17 | class CustomerDownloadableProductsTest extends GraphQlAbstract
|
21 | 18 | {
|
22 |
| - /** |
23 |
| - * @var QuoteFactory |
24 |
| - */ |
25 |
| - protected $quoteFactory; |
26 |
| - |
27 |
| - /** |
28 |
| - * @var QuoteResource |
29 |
| - */ |
30 |
| - protected $quoteResource; |
31 |
| - |
32 | 19 | /**
|
33 | 20 | * @var CustomerTokenServiceInterface
|
34 | 21 | */
|
35 | 22 | private $customerTokenService;
|
36 | 23 |
|
37 | 24 | /**
|
38 |
| - * @var CartManagementInterface |
| 25 | + * @inheritdoc |
39 | 26 | */
|
40 |
| - private $cartManagement; |
| 27 | + protected function setUp() |
| 28 | + { |
| 29 | + $objectManager = Bootstrap::getObjectManager(); |
| 30 | + $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); |
| 31 | + } |
41 | 32 |
|
42 | 33 | /**
|
43 | 34 | * @magentoApiDataFixture Magento/Customer/_files/customer.php
|
44 |
| - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/downloadable_product.php |
45 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php |
46 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_downloadable_product.php |
47 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/enable_offline_payment_methods.php |
48 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php |
49 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_checkmo_payment_method.php |
| 35 | + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php |
| 36 | + * @magentoApiDataFixture Magento/Downloadable/_files/customer_order_with_downloadable_product.php |
50 | 37 | */
|
51 | 38 | public function testCustomerDownloadableProducts()
|
52 | 39 | {
|
53 |
| - $quote = $this->quoteFactory->create(); |
54 |
| - $this->quoteResource->load($quote, 'test_quote', 'reserved_order_id'); |
55 |
| - $this->cartManagement->placeOrder($quote->getId()); |
56 |
| - |
57 | 40 | $query = $this->getQuery();
|
58 | 41 | $response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
|
59 | 42 |
|
@@ -88,43 +71,6 @@ public function testCustomerHasNoOrders()
|
88 | 71 | self::assertCount(0, $response['customerDownloadableProducts']['items']);
|
89 | 72 | }
|
90 | 73 |
|
91 |
| - /** |
92 |
| - * @magentoApiDataFixture Magento/Customer/_files/customer.php |
93 |
| - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php |
94 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/enable_offline_shipping_methods.php |
95 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/enable_offline_payment_methods.php |
96 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php |
97 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php |
98 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php |
99 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php |
100 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php |
101 |
| - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_checkmo_payment_method.php |
102 |
| - */ |
103 |
| - public function testCustomerHasNoDownloadableProducts() |
104 |
| - { |
105 |
| - $quote = $this->quoteFactory->create(); |
106 |
| - $this->quoteResource->load($quote, 'test_quote', 'reserved_order_id'); |
107 |
| - $this->cartManagement->placeOrder($quote->getId()); |
108 |
| - |
109 |
| - $query = $this->getQuery(); |
110 |
| - $response = $this->graphQlQuery($query, [], '', $this->getHeaderMap()); |
111 |
| - |
112 |
| - self::assertArrayHasKey('items', $response['customerDownloadableProducts']); |
113 |
| - self::assertCount(0, $response['customerDownloadableProducts']['items']); |
114 |
| - } |
115 |
| - |
116 |
| - /** |
117 |
| - * @inheritdoc |
118 |
| - */ |
119 |
| - protected function setUp() |
120 |
| - { |
121 |
| - $objectManager = Bootstrap::getObjectManager(); |
122 |
| - $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); |
123 |
| - $this->quoteFactory = $objectManager->get(QuoteFactory::class); |
124 |
| - $this->quoteResource = $objectManager->get(QuoteResource::class); |
125 |
| - $this->cartManagement = $objectManager->get(CartManagementInterface::class); |
126 |
| - } |
127 |
| - |
128 | 74 | /**
|
129 | 75 | * @return string
|
130 | 76 | */
|
@@ -154,7 +100,6 @@ private function getQuery(): string
|
154 | 100 | private function getHeaderMap( string $username = '[email protected]', string $password = 'password'): array
|
155 | 101 | {
|
156 | 102 | $customerToken = $this->customerTokenService->createCustomerAccessToken($username, $password);
|
157 |
| - $headerMap = ['Authorization' => 'Bearer ' . $customerToken]; |
158 |
| - return $headerMap; |
| 103 | + return ['Authorization' => 'Bearer ' . $customerToken]; |
159 | 104 | }
|
160 | 105 | }
|
0 commit comments