SearchTest::testMaximumPriceGetterAndSetter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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