-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathPriceTest.php
More file actions
129 lines (119 loc) · 5.6 KB
/
Copy pathPriceTest.php
File metadata and controls
129 lines (119 loc) · 5.6 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace WalmartTests;
include __DIR__ . '/../vendor/autoload.php';
use GuzzleHttp\Command\Exception\CommandClientException;
use Sil\PhpEnv\Env;
use Walmart\Price;
class PriceTest extends \PHPUnit_Framework_TestCase
{
public $config = [];
public $proxy = null;
//public $proxy = 'tcp://localhost:8888';
public $verifySsl = false;
public $env = Price::ENV_MOCK;
public $debugOutput = false;
public function __construct()
{
$this->config = [
'max_retries' => 0,
'http_client_options' => [
'defaults' => [
'proxy' => $this->proxy,
'verify' => $this->verifySsl,
]
],
'consumerId' => Env::get('CONSUMER_ID', 'hw30cqp3-35fi-1bi0-3312-hw9fgm30d2p4'),
'privateKey' => Env::get('PRIVATE_KEY', 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKzXEfCYdnBNkKAwVbCpg/tR40WixoZtiuEviSEi4+LdnYAAPy57Qw6+9eqJGTh9iCB2wP/I8lWh5TZ49Hq/chjTCPeJiOqi6bvX1xzyBlSq2ElSY3iEVKeVoQG/5f9MYQLEj5/vfTWSNASsMwnNeBbbHcV1S1aY9tOsXCzRuxapAgMBAAECgYBjkM1j1OA9l2Ed9loWl8BQ8X5D6h4E6Gudhx2uugOe9904FGxRIW6iuvy869dchGv7j41ki+SV0dpRw+HKKCjYE6STKpe0YwIm/tml54aNDQ0vQvF8JWILca1a7v3Go6chf3Ib6JPs6KVsUuNo+Yd+jKR9GAKgnDeXS6NZlTBUAQJBANex815VAySumJ/n8xR+h/dZ2V5qGj6wu3Gsdw6eNYKQn3I8AGQw8N4yzDUoFnrQxqDmP3LOyr3/zgOMNTdszIECQQDNIxiZOVl3/Sjyxy9WHMk5qNfSf5iODynv1OlTG+eWao0Wj/NdfLb4pwxRsf4XZFZ1SQNkbNne7+tEO8FTG1YpAkAwNMY2g/ty3E6iFl3ea7UJlBwfnMkGz8rkye3F55f/+UCZcE2KFuIOVv4Kt03m3vg1h6AQkaUAN8acRl6yZ2+BAkEAke2eiRmYANiR8asqjGqr5x2qcm8ceiplXdwrI1kddQ5VUbCTonSewOIszEz/gWp6arLG/ADHOGWaCo8rptAyiQJACXd1ddXUAKs6x3l752tSH8dOde8nDBgF86NGvgUnBiAPPTmJHuhWrmOZmNaB68PsltEiiFwWByGFV+ld9VKmKg=='),
'wmConsumerChannelType' => Env::get('WM_CONSUMER_CHANNEL_TYPE', 'ABC123'),
];
parent::__construct();
}
public function testBulk()
{
$client = $this->getClient();
try {
$update = $client->bulk([
'PriceFeed' => [
'PriceHeader' => [
'version' => '1.5',
],
'Price' => [
[
'itemIdentifier' => [
'sku' => '1131270'
],
'pricingList' => [
'pricing' => [
'currentPrice' => [
'value' => [
'currency' => 'USD',
'amount' => '4.00',
],
],
'currentPriceType' => 'BASE',
'comparisonPrice' => [
'value' => [
'currency' => 'USD',
'amount' => '5.99',
],
],
'priceDisplayCode' => [
'submapType' => 'CHECKOUT',
],
'effectiveDate' => '2016-07-02T12:38:43-04:00',
'expirationDate' => '2016-08-02T12:38:43-04:00',
]
],
],
[
'itemIdentifier' => [
'sku' => '2435543'
],
'pricingList' => [
'pricing' => [
'currentPrice' => [
'value' => [
'currency' => 'USD',
'amount' => '4.00',
],
],
'currentPriceType' => 'BASE',
'comparisonPrice' => [
'value' => [
'currency' => 'USD',
'amount' => '5.99',
],
],
'priceDisplayCode' => [
'submapType' => 'CHECKOUT',
],
'effectiveDate' => '2016-07-02T12:38:43-04:00',
'expirationDate' => '2016-08-02T12:38:43-04:00',
]
],
],
],
],
]);
$this->assertEquals(200, $update['statusCode']);
$this->assertNotNull($update['feedId']);
$this->debug($update);
} catch (CommandClientException $e) {
$error = $e->getResponse()->getHeader('X-Error');
$this->fail($e->getMessage() . 'Error: ' . $error);
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
private function getClient($extraConfig = [])
{
$config = array_merge_recursive($this->config, $extraConfig);
return new Price($config, $this->env);
}
private function debug($output)
{
if ($this->debugOutput) {
fwrite(STDERR, print_r($output, true));
}
}
}