GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#99)
by
unknown
07:26
created

LookupTest::testSetter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/*
3
 * Copyright 2013 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\Lookup;
21
22
class LookupTest extends \PHPUnit_Framework_TestCase
23
{
24
    public function testSetter()
25
    {
26
        $lookup = new Lookup();
27
        $lookup->setItemId('B1234');
28
    }
29
30
    /**
31
     * @expectedException \Exception
32
     */
33
    public function testSettersNegative()
34
    {
35
        $lookup = new Lookup();
36
        $lookup->setItemIds(
37
            array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
38
        );
39
    }
40
41
    public function testMultiItemSet()
42
    {
43
        $lookup = new Lookup();
44
        $lookup->setItemIds(array(1, 2, 3, 4));
45
46
        $itemQuery = $lookup->getItemId();
47
48
        static::assertSame('1,2,3,4', $itemQuery);
49
    }
50
51
    public function testGetName()
52
    {
53
        $lookup = new Lookup();
54
        static::assertEquals('ItemLookup', $lookup->getName());
55
    }
56
57
    public function testGetIdType()
58
    {
59
        $lookup = new Lookup();
60
        $valididTypes = array(
61
            'ASIN',
62
            'SKU',
63
            'UPC',
64
            'EAN',
65
            'ISBN',
66
            Lookup::TYPE_ASIN,
67
            Lookup::TYPE_SKU,
68
            Lookup::TYPE_UPC,
69
            Lookup::TYPE_EAN,
70
            Lookup::TYPE_ISBN
71
        );
72
        foreach ($valididTypes as $valididType) {
73
            $lookup->setIdType($valididType);
74
            static::assertEquals($valididType, $lookup->getIdType());
75
        }
76
    }
77
78
    /**
79
     * @dataProvider providerSetIdTypeAffectsSearchIndex
80
     *
81
     * @param string $idType
82
     * @param string|null $expectedSearchIndex
83
     */
84
    public function testSetIdTypeAffectsSearchIndex($idType, $expectedSearchIndex)
85
    {
86
        $lookup = new Lookup();
87
        $lookup->setIdType($idType);
88
89
        $parameters = $lookup->getOperationParameter();
90
91
        if ($expectedSearchIndex === null) {
92
            static::assertArrayNotHasKey('SearchIndex', $parameters);
93
        } else {
94
            static::assertSame($expectedSearchIndex, $parameters['SearchIndex']);
95
        }
96
    }
97
98
    /**
99
     * @return array
100
     */
101
    public function providerSetIdTypeAffectsSearchIndex()
102
    {
103
        return array(
104
            array(Lookup::TYPE_ASIN, null),
105
            array(Lookup::TYPE_SKU, 'All'),
106
            array(Lookup::TYPE_UPC, 'All'),
107
            array(Lookup::TYPE_EAN, 'All'),
108
            array(Lookup::TYPE_ISBN, 'All')
109
        );
110
    }
111
112
    /**
113
     * @expectedException InvalidArgumentException
114
     */
115
    public function testExceptionWhenPassingWrongIdType()
116
    {
117
        $lookup = new Lookup();
118
        $lookup->setIdType('Invalid IdType');
119
    }
120
121
    public function testGetSearchIndex()
122
    {
123
        $lookup = new Lookup();
124
        static::assertEquals(null, $lookup->getSearchIndex());
125
        $lookup->setSearchIndex('Appliances');
126
        static::assertEquals('Appliances', $lookup->getSearchIndex());
127
    }
128
129
    public function testConditionGetterAndSetter()
130
    {
131
        $lookup = new Lookup();
132
        static::assertEquals(null, $lookup->getCondition());
133
        $lookup->setCondition('All');
134
        static::assertEquals('All', $lookup->getCondition());
135
    }
136
137
    public function testGetItemId()
138
    {
139
        $lookup = new Lookup();
140
        static::assertEquals(null, $lookup->getItemId());
141
        $lookup->setItemId('B0117IJ4LE');
142
        static::assertEquals('B0117IJ4LE', $lookup->getItemId());
143
    }
144
145
    public function testGetCondition()
146
    {
147
        $lookup = new Lookup();
148
        static::assertEquals(null, $lookup->getCondition());
149
        $lookup->setCondition('Used');
150
        static::assertEquals('Used', $lookup->getCondition());
151
    }
152
153
    public function testGetItemId()
154
    {
155
        $lookup = new Lookup();
156
        $lookup->setItemId('B0117IJ4LE');
157
        $this->assertEquals('B0117IJ4LE', $lookup->getItemId());
158
    }
159
160
    public function testGetCondition()
161
    {
162
        $lookup = new Lookup();
163
        $lookup->setCondition('Used');
164
        $this->assertEquals('Used', $lookup->getCondition());
165
    }
166
}
167