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.

QuantumViewTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Octante\UpsAPIBundle\Tests\Unit\Library;
4
5
/*
6
 * This file is part of the UpsAPIBundle package.
7
 *
8
 * (c) Issel Guberna <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use Octante\UpsAPIBundle\Library\QuantumViewWrapper;
15
16
class QuantumViewTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @var
20
     */
21
    private $quantumViewMock;
22
23
    public function setUp()
24
    {
25
        $this->quantumViewMock = $this->getMock('Ups\QuantumView');
26
    }
27
28
    /**
29
     * when: getSubscriptionIsCalled
30
     * should: callUpsQuantumViewGetSubscriptionMethod.
31
     */
32
    public function testQuantumViewGetSubscriptionMethodIsCalled()
33
    {
34
        $name = 'name';
35
        $beginDateTime = 'begin date time';
36
        $endDateTime = 'end date time';
37
        $fileName = 'filename';
38
        $bookmark = 'bookmark';
39
40
        $this
41
            ->quantumViewMock
42
            ->expects($this->once())
43
            ->method('getSubscription')
44
            ->with(
45
                $name,
46
                $beginDateTime,
47
                $endDateTime,
48
                $fileName,
49
                $bookmark
50
            );
51
52
        $sut = new QuantumViewWrapper($this->quantumViewMock);
53
54
        $sut->getSubscription(
55
            $name,
56
            $beginDateTime,
57
            $endDateTime,
58
            $fileName,
59
            $bookmark
60
        );
61
    }
62
63
    /**
64
     * when: getBookmarkIsCalled
65
     * should: callUpsQuantumViewGetBookmarkMethod.
66
     */
67
    public function testQuantumViewGetBookmarkMethodIsCalled()
68
    {
69
        $sut = new QuantumViewWrapper($this->quantumViewMock);
70
71
        $this
72
            ->quantumViewMock
73
            ->expects($this->once())
74
            ->method('getBookmark');
75
76
        $sut->getBookmark();
0 ignored issues
show
Unused Code introduced by
The call to the method Octante\UpsAPIBundle\Lib...wWrapper::getBookmark() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
77
    }
78
79
    /**
80
     * when: hasBookmarkIsCalled
81
     * should: callUpsQuantumViewHasBookmarkMethod.
82
     */
83
    public function testQuantumViewHasBookmarkMethodIsCalled()
84
    {
85
        $sut = new QuantumViewWrapper($this->quantumViewMock);
86
87
        $this
88
            ->quantumViewMock
89
            ->expects($this->once())
90
            ->method('hasBookmark');
91
92
        $sut->hasBookmark();
0 ignored issues
show
Unused Code introduced by
The call to the method Octante\UpsAPIBundle\Lib...wWrapper::hasBookmark() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
93
    }
94
95
    /**
96
     * when: setBookmarkIsCalled
97
     * should: callUpsQuantumViewSetBookmarkMethod.
98
     */
99
    public function testQuantumViewSetBookmarkMethodIsCalled()
100
    {
101
        $sut = new QuantumViewWrapper($this->quantumViewMock);
102
        $bookmarkMock = 'bookmark name';
103
104
        $this
105
            ->quantumViewMock
106
            ->expects($this->once())
107
            ->method('setBookmark')
108
            ->with($bookmarkMock);
109
110
        $sut->setBookmark($bookmarkMock);
111
    }
112
113
    /**
114
     * when: getRequestIsCalled
115
     * should: callUpsQuantumViewGetRequestMethod.
116
     */
117
    public function testQuantumViewGetRequestMethodIsCalled()
118
    {
119
        $requestMock = $this->getMock('Ups\Request');
120
        $this
121
            ->quantumViewMock
122
            ->method('getRequest')
123
            ->willReturn($requestMock);
124
125
        $sut = new QuantumViewWrapper($this->quantumViewMock);
126
        $sut->setRequest($requestMock);
127
        $request = $sut->getRequest();
128
        $this->assertInstanceOf('Ups\Request', $request);
129
    }
130
131
    /**
132
     * when: getResponseIsCalled
133
     * should: callUpsGetResponseMethod.
134
     */
135 View Code Duplication
    public function testQuantumViewGetResponseMethodIsCalled()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
136
    {
137
        $responseMock = $this->getMock('Ups\Response');
138
        $this
139
            ->quantumViewMock
140
            ->method('getResponse')
141
            ->willReturn($responseMock);
142
143
        $sut = new QuantumViewWrapper($this->quantumViewMock);
144
        $sut->setResponse($responseMock);
145
        $response = $sut->getResponse();
146
        $this->assertInstanceOf('Ups\Response', $response);
147
    }
148
}
149