Passed
Pull Request — develop (#53)
by Luís
03:03
created

CancellationResponseTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 45
loc 45
rs 10

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
namespace PHPSC\PagSeguro\Purchases\Subscriptions;
3
4
use DateTime;
5
6
/**
7
 * @author Adelar Tiemann Junior <[email protected]>
8
 */
9
class CancellationResponseTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var CancellationResponse
13
     */
14
    private $cancellationResponse;
15
16
    /**
17
     * @var DateTime
18
     */
19
    private $date;
20
21
    public function setUp()
22
    {
23
        $this->date = new DateTime('2015-01-01');
24
        $this->cancellationResponse = new CancellationResponse('someStatus', $this->date);
25
    }
26
27
    /**
28
     * @test
29
     */
30
    public function constructShouldConfigureTheAttributes()
31
    {
32
        $this->assertAttributeEquals('someStatus', 'status', $this->cancellationResponse);
33
        $this->assertAttributeSame($this->date, 'date', $this->cancellationResponse);
34
    }
35
36
    /**
37
     * @test
38
     * @depends constructShouldConfigureTheAttributes
39
     */
40
    public function getStatusShouldReturnTheConfiguredStatus()
41
    {
42
        $this->assertEquals('someStatus', $this->cancellationResponse->getStatus());
43
    }
44
45
    /**
46
     * @test
47
     * @depends constructShouldConfigureTheAttributes
48
     */
49
    public function getDateShouldReturnTheConfiredDate()
50
    {
51
        $this->assertSame($this->date, $this->cancellationResponse->getDate());
52
    }
53
}
54