This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Grayloon \Magento \Api ;
4
+
5
+ class Orders extends AbstractApi
6
+ {
7
+ /**
8
+ * Lists orders that match specified search criteria.
9
+ *
10
+ * @param int $pageSize
11
+ * @param int $currentPage
12
+ * @param array $filters
13
+ *
14
+ * @return array
15
+ */
16
+ public function all ($ pageSize = 50 , $ currentPage = 1 , $ filters = [])
17
+ {
18
+ return $ this ->get ('/orders ' , array_merge ($ filters , [
19
+ 'searchCriteria[pageSize] ' => $ pageSize ,
20
+ 'searchCriteria[currentPage] ' => $ currentPage ,
21
+ ]));
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Grayloon \Magento \Tests ;
4
+
5
+ use Grayloon \Magento \Api \Orders ;
6
+ use Grayloon \Magento \MagentoFacade ;
7
+ use Illuminate \Support \Facades \Http ;
8
+
9
+ class OrdersTest extends TestCase
10
+ {
11
+ public function test_can_call_magento_api_orders ()
12
+ {
13
+ $ this ->assertInstanceOf (Orders::class, MagentoFacade::api ('orders ' ));
14
+ }
15
+
16
+ public function test_can_call_magento_api_orders_all ()
17
+ {
18
+ Http::fake ([
19
+ '*rest/all/V1/orders* ' => Http::response ([], 200 ),
20
+ ]);
21
+
22
+ $ api = MagentoFacade::api ('orders ' )->all ();
23
+
24
+ $ this ->assertTrue ($ api ->ok ());
25
+ }
26
+
27
+ public function test_can_call_magento_api_orders_all_with_filter ()
28
+ {
29
+ Http::fake ([
30
+ '*rest/all/V1/orders* ' => Http::response ([], 200 ),
31
+ ]);
32
+
33
+ $ api = MagentoFacade::api ('orders ' )->all (1 , 1 , [
34
+ 'searchCriteria[filterGroups][0][filters][0][field] ' => 'customer_email ' ,
35
+ 'searchCriteria[filterGroups][0][filters][0][value] ' =>
'[email protected] ' ,
36
+ ]);
37
+
38
+ $ this ->assertTrue ($ api ->ok ());
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments