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\Search; |
21
|
|
|
use PHPUnit\Framework\TestCase; |
22
|
|
|
|
23
|
|
|
class SearchTest extends TestCase |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @expectedException InvalidArgumentException |
27
|
|
|
*/ |
28
|
|
|
public function testSearchException() |
29
|
|
|
{ |
30
|
|
|
$search = new Search(); |
31
|
|
|
$search->setPage(11); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @expectedException InvalidArgumentException |
36
|
|
|
*/ |
37
|
|
|
public function testMaximumPriceException() |
38
|
|
|
{ |
39
|
|
|
$search = new Search(); |
40
|
|
|
$search->setMaximumPrice(-1); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testMaximumPriceGetterAndSetter() |
44
|
|
|
{ |
45
|
|
|
$search = new Search(); |
46
|
|
|
|
47
|
|
|
$object = $search->setMaximumPrice(100); |
48
|
|
|
|
49
|
|
|
$this->assertSame($search, $object); |
50
|
|
|
$this->assertEquals(100, $search->getMaximumPrice()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testMinimumPriceGetterAndSetter() |
54
|
|
|
{ |
55
|
|
|
$search = new Search(); |
56
|
|
|
|
57
|
|
|
$object = $search->setMinimumPrice(100); |
58
|
|
|
|
59
|
|
|
$this->assertSame($search, $object); |
60
|
|
|
$this->assertEquals(100, $search->getMinimumPrice()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @expectedException InvalidArgumentException |
65
|
|
|
*/ |
66
|
|
|
public function testMinimumPriceException() |
67
|
|
|
{ |
68
|
|
|
$search = new Search(); |
69
|
|
|
$search->setMinimumPrice('helloworld'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function testSearchValidPage() |
73
|
|
|
{ |
74
|
|
|
$search = new Search(); |
75
|
|
|
$search->setPage(1); |
76
|
|
|
|
77
|
|
|
$this->assertEquals(1, $search->getItemPage()); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function testConditionGetterAndSetter() |
81
|
|
|
{ |
82
|
|
|
$search = new Search(); |
83
|
|
|
$search->setCondition('All'); |
84
|
|
|
$this->assertEquals('All', $search->getCondition()); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function testAvailabilityGetterAndSetter() |
88
|
|
|
{ |
89
|
|
|
$search = new Search(); |
90
|
|
|
$search->setAvailability('Available'); |
91
|
|
|
$this->assertEquals('Available', $search->getAvailability()); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function testNodeGetterAndSetter() |
95
|
|
|
{ |
96
|
|
|
$search = new Search(); |
97
|
|
|
$this->assertEquals(null, $search->getBrowseNode()); |
98
|
|
|
$search->setBrowseNode(10967581); |
99
|
|
|
$this->assertEquals(10967581, $search->getBrowseNode()); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function testGetCategory() |
103
|
|
|
{ |
104
|
|
|
$search = new Search(); |
105
|
|
|
$this->assertEquals(null, $search->getCategory()); |
106
|
|
|
$search->setCategory('All'); |
107
|
|
|
$this->assertEquals('All', $search->getCategory()); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function testGetKeywords() |
111
|
|
|
{ |
112
|
|
|
$search = new Search(); |
113
|
|
|
$this->assertEquals(null, $search->getKeywords()); |
114
|
|
|
$search->setKeywords('4k tv'); |
115
|
|
|
$this->assertEquals('4k tv', $search->getKeywords()); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function testGetSort() |
119
|
|
|
{ |
120
|
|
|
$search = new Search(); |
121
|
|
|
$this->assertEquals(null, $search->getSort()); |
122
|
|
|
$search->setSort('salesrank'); |
123
|
|
|
$this->assertEquals('salesrank', $search->getSort()); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function testGetPage() |
127
|
|
|
{ |
128
|
|
|
$search = new Search(); |
129
|
|
|
$this->assertEquals(null, $search->getPage()); |
130
|
|
|
$search->setPage(3); |
131
|
|
|
$this->assertEquals(3, $search->getPage()); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function testGetMinimumPrice() |
135
|
|
|
{ |
136
|
|
|
$search = new Search(); |
137
|
|
|
$this->assertEquals(null, $search->getMinimumPrice()); |
138
|
|
|
$search->setMinimumPrice(899); |
139
|
|
|
$this->assertEquals(899, $search->getMinimumPrice()); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function testGetMaximumPrice() |
143
|
|
|
{ |
144
|
|
|
$search = new Search(); |
145
|
|
|
$this->assertEquals(null, $search->getMaximumPrice()); |
146
|
|
|
$search->setMaximumPrice(899); |
147
|
|
|
$this->assertEquals(899, $search->getMaximumPrice()); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function testGetCondition() |
151
|
|
|
{ |
152
|
|
|
$search = new Search(); |
153
|
|
|
$this->assertEquals(null, $search->getCondition()); |
154
|
|
|
$search->setCondition('Collectible'); |
155
|
|
|
$this->assertEquals('Collectible', $search->getCondition()); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function testGetAvailability() |
159
|
|
|
{ |
160
|
|
|
$search = new Search(); |
161
|
|
|
$this->assertEquals(null, $search->getAvailability()); |
162
|
|
|
$search->setAvailability('Available'); |
163
|
|
|
$this->assertEquals('Available', $search->getAvailability()); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
public function testGetBrowseNode() |
167
|
|
|
{ |
168
|
|
|
$search = new Search(); |
169
|
|
|
$this->assertEquals(null, $search->getBrowseNode()); |
170
|
|
|
$search->setBrowseNode(123); |
171
|
|
|
$this->assertEquals(123, $search->getBrowseNode()); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|