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.

LookupTest::testGetIdType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

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