1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright 2016 Jan Eichhorn <[email protected]> |
4
|
|
|
* |
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
6
|
|
|
* you may not use this file except in compliance with the License. |
7
|
|
|
* You may obtain a copy of the License at |
8
|
|
|
* |
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
10
|
|
|
* |
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14
|
|
|
* See the License for the specific language governing permissions and |
15
|
|
|
* limitations under the License. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace ApaiIO\Test\Operations\Types; |
19
|
|
|
|
20
|
|
|
use ApaiIO\Operations\CartCreate; |
21
|
|
|
use PHPUnit\Framework\TestCase; |
22
|
|
|
|
23
|
|
|
class CartCreateTest extends TestCase |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* the subject |
27
|
|
|
* |
28
|
|
|
* @var CartCreate |
29
|
|
|
*/ |
30
|
|
|
private $cartCreate; |
31
|
|
|
|
32
|
|
|
protected function setUp() |
33
|
|
|
{ |
34
|
|
|
parent::setUp(); |
35
|
|
|
$this->cartCreate = new CartCreate(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
protected function tearDown() |
39
|
|
|
{ |
40
|
|
|
$this->cartCreate = null; |
41
|
|
|
parent::tearDown(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testName() |
45
|
|
|
{ |
46
|
|
|
$this->assertEquals("CartCreate", $this->cartCreate->getName()); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testAddItem() |
50
|
|
|
{ |
51
|
|
|
$operationParameters = $this->cartCreate->getOperationParameter(); |
52
|
|
|
$this->assertEquals([], $operationParameters); |
53
|
|
|
|
54
|
|
|
$asin = __LINE__; |
55
|
|
|
$this->cartCreate->addItem($asin, 2); |
56
|
|
|
|
57
|
|
|
$operationParameters = $this->cartCreate->getOperationParameter(); |
58
|
|
|
$this->assertEquals($asin, $operationParameters["Item.1.ASIN"]); |
59
|
|
|
$this->assertEquals(2, $operationParameters["Item.1.Quantity"]); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testAddItemByOfferListingId() |
63
|
|
|
{ |
64
|
|
|
$operationParameters = $this->cartCreate->getOperationParameter(); |
65
|
|
|
$this->assertEquals([], $operationParameters); |
66
|
|
|
|
67
|
|
|
$asin = __LINE__; |
68
|
|
|
$this->cartCreate->addItem($asin, 2, false); |
69
|
|
|
|
70
|
|
|
$operationParameters = $this->cartCreate->getOperationParameter(); |
71
|
|
|
$this->assertEquals($asin, $operationParameters["Item.1.OfferListingId"]); |
72
|
|
|
$this->assertEquals(2, $operationParameters["Item.1.Quantity"]); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testAddItemIncrementsCounter() |
76
|
|
|
{ |
77
|
|
|
$asin = __LINE__; |
78
|
|
|
$this->cartCreate->addItem($asin, 2); |
79
|
|
|
$this->cartCreate->addItem($asin, 2); |
80
|
|
|
|
81
|
|
|
$operationParameters = $this->cartCreate->getOperationParameter(); |
82
|
|
|
$this->assertEquals($asin, $operationParameters["Item.2.ASIN"]); |
83
|
|
|
$this->assertEquals(2, $operationParameters["Item.2.Quantity"]); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|