|
16 | 16 | */ |
17 | 17 | class OrdersTest extends GraphQlAbstract |
18 | 18 | { |
19 | | - /** |
20 | | - * @var CustomerTokenServiceInterface |
21 | | - */ |
22 | | - private $customerTokenService; |
| 19 | + /** |
| 20 | + * @var CustomerTokenServiceInterface |
| 21 | + */ |
| 22 | + private $customerTokenService; |
23 | 23 |
|
24 | | - /** |
25 | | - * {@inheritdoc} |
26 | | - */ |
27 | 24 | protected function setUp() |
28 | 25 | { |
29 | 26 | parent::setUp(); |
30 | | - $objectManager = Bootstrap::getObjectManager(); |
31 | | - $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); |
| 27 | + $this->customerTokenService = Bootstrap::getObjectManager()->get(CustomerTokenServiceInterface::class); |
32 | 28 | } |
33 | 29 |
|
34 | | - /** |
35 | | - * @magentoApiDataFixture Magento/Customer/_files/customer.php |
36 | | - * @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php |
37 | | - */ |
| 30 | + /** |
| 31 | + * @magentoApiDataFixture Magento/Customer/_files/customer.php |
| 32 | + * @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php |
| 33 | + */ |
38 | 34 | public function testOrdersQuery() |
39 | 35 | { |
40 | | - $query = |
41 | | - <<<QUERY |
| 36 | + $query = |
| 37 | + <<<QUERY |
42 | 38 | query { |
43 | 39 | customerOrders { |
44 | 40 | items { |
45 | | - id |
46 | | - increment_id |
47 | | - created_at |
48 | | - grand_total |
49 | | - status |
50 | | - } |
| 41 | + id |
| 42 | + increment_id |
| 43 | + created_at |
| 44 | + grand_total |
| 45 | + status |
| 46 | + } |
51 | 47 | } |
52 | 48 | } |
53 | 49 | QUERY; |
54 | 50 |
|
55 | | - $currentEmail = '[email protected]'; |
56 | | - $currentPassword = 'password'; |
57 | | - |
58 | | - $response = $this->graphQlQuery($query, [], '', $this->getCustomerAuthHeaders($currentEmail, $currentPassword)); |
| 51 | + $currentEmail = '[email protected]'; |
| 52 | + $currentPassword = 'password'; |
| 53 | + $response = $this->graphQlQuery($query, [], '', $this->getCustomerAuthHeaders($currentEmail, $currentPassword)); |
59 | 54 |
|
60 | | - $expectedData = [ |
61 | | - [ |
62 | | - 'increment_id' => '100000002', |
63 | | - 'status' => 'processing', |
64 | | - 'grand_total' => 120.00 |
65 | | - ], |
66 | | - [ |
67 | | - 'increment_id' => '100000003', |
68 | | - 'status' => 'processing', |
69 | | - 'grand_total' => 130.00 |
70 | | - ], |
71 | | - [ |
72 | | - 'increment_id' => '100000004', |
73 | | - 'status' => 'closed', |
74 | | - 'grand_total' => 140.00 |
75 | | - ], |
76 | | - [ |
77 | | - 'increment_id' => '100000005', |
78 | | - 'status' => 'complete', |
79 | | - 'grand_total' => 150.00 |
80 | | - ], |
81 | | - [ |
82 | | - 'increment_id' => '100000006', |
83 | | - 'status' => 'complete', |
84 | | - 'grand_total' => 160.00 |
85 | | - ] |
86 | | - ]; |
| 55 | + $expectedData = [ |
| 56 | + [ |
| 57 | + 'increment_id' => '100000002', |
| 58 | + 'status' => 'processing', |
| 59 | + 'grand_total' => 120.00 |
| 60 | + ], |
| 61 | + [ |
| 62 | + 'increment_id' => '100000003', |
| 63 | + 'status' => 'processing', |
| 64 | + 'grand_total' => 130.00 |
| 65 | + ], |
| 66 | + [ |
| 67 | + 'increment_id' => '100000004', |
| 68 | + 'status' => 'closed', |
| 69 | + 'grand_total' => 140.00 |
| 70 | + ], |
| 71 | + [ |
| 72 | + 'increment_id' => '100000005', |
| 73 | + 'status' => 'complete', |
| 74 | + 'grand_total' => 150.00 |
| 75 | + ], |
| 76 | + [ |
| 77 | + 'increment_id' => '100000006', |
| 78 | + 'status' => 'complete', |
| 79 | + 'grand_total' => 160.00 |
| 80 | + ] |
| 81 | + ]; |
87 | 82 |
|
88 | | - $actualData = $response['customerOrders']['items']; |
| 83 | + $actualData = $response['customerOrders']['items']; |
89 | 84 |
|
90 | | - foreach ($expectedData as $key => $data) { |
91 | | - $this->assertEquals($data['increment_id'], $actualData[$key]['increment_id']); |
92 | | - $this->assertEquals($data['grand_total'], $actualData[$key]['grand_total']); |
93 | | - $this->assertEquals($data['status'], $actualData[$key]['status']); |
94 | | - } |
| 85 | + foreach ($expectedData as $key => $data) { |
| 86 | + $this->assertEquals($data['increment_id'], $actualData[$key]['increment_id']); |
| 87 | + $this->assertEquals($data['grand_total'], $actualData[$key]['grand_total']); |
| 88 | + $this->assertEquals($data['status'], $actualData[$key]['status']); |
| 89 | + } |
95 | 90 | } |
96 | 91 |
|
97 | | - /** |
98 | | - * @param string $email |
99 | | - * @param string $password |
100 | | - * @return array |
101 | | - * @throws \Magento\Framework\Exception\AuthenticationException |
102 | | - */ |
103 | | - private function getCustomerAuthHeaders(string $email, string $password): array |
104 | | - { |
105 | | - $customerToken = $this->customerTokenService->createCustomerAccessToken($email, $password); |
106 | | - return ['Authorization' => 'Bearer ' . $customerToken]; |
107 | | - } |
| 92 | + /** |
| 93 | + * @param string $email |
| 94 | + * @param string $password |
| 95 | + * @return array |
| 96 | + * @throws \Magento\Framework\Exception\AuthenticationException |
| 97 | + */ |
| 98 | + private function getCustomerAuthHeaders(string $email, string $password): array |
| 99 | + { |
| 100 | + $customerToken = $this->customerTokenService->createCustomerAccessToken($email, $password); |
| 101 | + return ['Authorization' => 'Bearer ' . $customerToken]; |
| 102 | + } |
108 | 103 | } |
0 commit comments