-
Notifications
You must be signed in to change notification settings - Fork 11
/
ExampleTest.php
66 lines (56 loc) · 1.86 KB
/
ExampleTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* @copyright Copyright (c) Wizacha
* @license Proprietary
*/
declare(strict_types=1);
namespace Wizaplace\SDK\Tests;
/**
* This is just here for example usages.
* Having them as runnable tests ensures that they are up to date.
*/
final class ExampleTest extends ApiTestCase
{
/**
* Shows how to make a simple product search without any filters.
* @test
*/
public function basicUsage()
{
// Setup
$marketplaceApiUri = 'http://wizaplace.loc/api/v1/'; // replace that value with your own
$httpClient = new \GuzzleHttp\Client(
[
'base_uri' => $marketplaceApiUri,
]
);
$wizaplaceClient = new \Wizaplace\SDK\ApiClient($httpClient);
$catalogService = new \Wizaplace\SDK\Catalog\CatalogService($wizaplaceClient);
// Search
$products = $catalogService->search();
// Just here so PHPUnit does not complain about the lack of assertions
$this->assertNotEmpty($products);
}
/**
* Shows how to use a service which requires authentication.
* @test
*/
public function authenticationUsage()
{
// Setup
$marketplaceApiUri = 'http://wizaplace.loc/api/v1/'; // replace that value with your own
$httpClient = new \GuzzleHttp\Client(
[
'base_uri' => $marketplaceApiUri,
]
);
$wizaplaceClient = new \Wizaplace\SDK\ApiClient($httpClient);
$orderService = new \Wizaplace\SDK\Order\OrderService($wizaplaceClient);
// Authentication
$wizaplaceClient->authenticate('customer-3@world-company.com', 'password-customer-3');
// Authenticated Action
$orders = $orderService->getOrders();
// Just here so PHPUnit does not complain about the lack of assertions
$this->assertEmpty($orders);
}
}