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.

RateTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 81
Duplicated Lines 16.05 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 13
loc 81
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testRateShopRatesMethodIsCalled() 0 12 1
A testRateGetRateMethodIsCalled() 0 14 1
A testRateGetRequestMethodIsCalled() 0 13 1
A testRateGetResponseMethodIsCalled() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\RateWrapper;
15
16
class RateTest extends \PHPUnit_Framework_TestCase
17
{
18
    private $rateMock;
19
20
    public function setUp()
21
    {
22
        $this->rateMock = $this->getMock('Ups\Rate');
23
    }
24
25
    /**
26
     * when: shopRatesIsCalled
27
     * should: callUpsRateShopRatesMethod.
28
     */
29
    public function testRateShopRatesMethodIsCalled()
30
    {
31
        $rateRequest = $this->getMock('Ups\Entity\RateRequest');
32
        $this->rateMock
33
            ->expects($this->once())
34
            ->method('shopRates')
35
            ->with($rateRequest);
36
37
        $sut = new RateWrapper($this->rateMock);
38
39
        $sut->shopRates($rateRequest);
40
    }
41
42
    /**
43
     * when: getRateIsCalled
44
     * should: callUpsRateGetRateMethod.
45
     */
46
    public function testRateGetRateMethodIsCalled()
47
    {
48
        $shipmentMock = $this->getMock('Ups\Entity\Shipment');
49
        $rateRequestMock = $this->getMock('Ups\Entity\RateRequest');
50
        $this->rateMock
51
            ->expects($this->once())
52
            ->method('getRate')
53
            ->willReturn($rateRequestMock);
54
55
        $sut = new RateWrapper($this->rateMock);
56
57
        $rateRequest = $sut->getRate($shipmentMock);
58
        $this->assertEquals($rateRequestMock, $rateRequest);
59
    }
60
61
    /**
62
     * when: getRequestIsCalled
63
     * should: callUpsRateGetRequestMethod.
64
     */
65
    public function testRateGetRequestMethodIsCalled()
66
    {
67
        $requestMock = $this->getMock('Ups\Request');
68
        $this
69
            ->rateMock
70
            ->method('getRequest')
71
            ->willReturn($requestMock);
72
73
        $sut = new RateWrapper($this->rateMock);
74
        $sut->setRequest($requestMock);
75
        $request = $sut->getRequest();
76
        $this->assertInstanceOf('Ups\Request', $request);
77
    }
78
79
    /**
80
     * when: getResponseIsCalled
81
     * should: callUpsRateGetResponseMethod.
82
     */
83 View Code Duplication
    public function testRateGetResponseMethodIsCalled()
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...
84
    {
85
        $responseMock = $this->getMock('Ups\Response');
86
        $this
87
            ->rateMock
88
            ->method('getResponse')
89
            ->willReturn($responseMock);
90
91
        $sut = new RateWrapper($this->rateMock);
92
        $sut->setResponse($responseMock);
93
        $response = $sut->getResponse();
94
        $this->assertInstanceOf('Ups\Response', $response);
95
    }
96
}
97