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
Push — master ( 3bb2ca...deaed9 )
by Jelte
01:08
created

SubscriptionPeriodTest   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 140
Duplicated Lines 10.71 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 17
c 2
b 1
f 1
lcom 1
cbo 2
dl 15
loc 140
rs 10

17 Methods

Rating   Name   Duplication   Size   Complexity  
A UnitMustBeValid() 0 5 1
A SettingUnitToWeeklyChecksMoment() 0 6 1
A SettingUnitToMonthlyChecksMoment() 0 6 1
A UnitCanBeSetRight() 0 5 1
A IntervalMustBeInteger() 0 5 1
A IntervalMustBePositive() 0 5 1
A IntervalMustNotBeTooBig() 0 5 1
A IntervalCanBeSetRight() 0 5 1
A MomentMustBeInt() 0 5 1
A MomentMustBePositive() 0 5 1
A MomentMustNotBeTooBig() 0 5 1
A MomentChecksUnit() 0 5 1
A MomentCanBeSetRight() 0 5 1
A unitProvider() 8 8 1
A intProvider() 0 9 1
A badUnitMomentComboProvider() 7 7 1
A createPeriod() 0 4 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 Ogone\Tests\Subscription;
4
5
use Ogone\Subscription\SubscriptionPeriod;
6
7
class SubscriptionPeriodTest extends \PHPUnit_Framework_TestCase
8
{
9
10
    /** @test */
11
    public function UnitMustBeValid()
12
    {
13
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
14
        $this->createPeriod('not an actual unit');
15
    }
16
17
    /** @test */
18
    public function SettingUnitToWeeklyChecksMoment()
19
    {
20
        $period = $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, 12, 8);
21
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
22
        $period->setUnit(SubscriptionPeriod::UNIT_WEEKLY);
23
    }
24
25
    /** @test */
26
    public function SettingUnitToMonthlyChecksMoment()
27
    {
28
        $period = $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, 12, 29);
29
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
30
        $period->setUnit(SubscriptionPeriod::UNIT_MONTHLY);
31
    }
32
33
    /**
34
     * @test
35
     * @dataProvider unitProvider
36
     */
37
    public function UnitCanBeSetRight($unit)
38
    {
39
        $period = $this->createPeriod($unit);
40
        $this->assertEquals($unit, $period->getUnit());
41
    }
42
43
    /** @test */
44
    public function IntervalMustBeInteger()
45
    {
46
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
47
        $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, 'not an int');
48
    }
49
50
    /** @test */
51
    public function IntervalMustBePositive()
52
    {
53
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
54
        $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, -12);
55
    }
56
57
    /** @test */
58
    public function IntervalMustNotBeTooBig()
59
    {
60
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
61
        $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, 150000000000000000);
62
    }
63
64
    /**
65
     * @test
66
     * @dataProvider intProvider
67
     */
68
    public function IntervalCanBeSetRight($interval)
69
    {
70
        $period = $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, $interval);
71
        $this->assertEquals($interval, $period->getInterval());
72
    }
73
74
    /** @test */
75
    public function MomentMustBeInt()
76
    {
77
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
78
        $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, 12, 'not an int');
79
    }
80
81
    /** @test */
82
    public function MomentMustBePositive()
83
    {
84
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
85
        $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, 12, -12);
86
    }
87
88
    /** @test */
89
    public function MomentMustNotBeTooBig()
90
    {
91
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
92
        $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, 12, 150000000000000000);
93
    }
94
95
    /**
96
     * @test
97
     * @dataProvider badUnitMomentComboProvider
98
     */
99
    public function MomentChecksUnit($unit, $interval)
100
    {
101
        $this->setExpectedException('InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
102
        $this->createPeriod($unit, 12, $interval);
103
    }
104
105
    /**
106
     * @test
107
     * @dataProvider intProvider
108
     */
109
    public function MomentCanBeSetRight($moment)
110
    {
111
        $period = $this->createPeriod(SubscriptionPeriod::UNIT_DAILY, 12, $moment);
112
        $this->assertEquals($moment, $period->getMoment());
113
    }
114
115 View Code Duplication
    public function unitProvider()
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...
116
    {
117
        return array(
118
            array(SubscriptionPeriod::UNIT_DAILY),
119
            array(SubscriptionPeriod::UNIT_WEEKLY),
120
            array(SubscriptionPeriod::UNIT_MONTHLY)
121
        );
122
    }
123
124
    public function intProvider()
125
    {
126
        return array(
127
            array(1),
128
            array(5),
129
            array(32),
130
            array(123546)
131
        );
132
    }
133
134 View Code Duplication
    public function badUnitMomentComboProvider()
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...
135
    {
136
        return array(
137
            array(SubscriptionPeriod::UNIT_WEEKLY, 8),
138
            array(SubscriptionPeriod::UNIT_MONTHLY, 29)
139
        );
140
    }
141
142
    protected function createPeriod($unit = SubscriptionPeriod::UNIT_DAILY, $interval = 12, $moment = 6)
143
    {
144
        return new SubscriptionPeriod($unit, $interval, $moment);
145
    }
146
}
147