Completed
Pull Request — develop (#48)
by Luís
02:58 queued 50s
created

ChargeResponseTest   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 ChargeResponseTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var ChargeResponse
13
     */
14
    private $chargeResponse;
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->chargeResponse = new ChargeResponse('someTransactionCode', $this->date);
25
    }
26
27
    /**
28
     * @test
29
     */
30
    public function constructShouldConfigureTheAttributes()
31
    {
32
        $this->assertAttributeEquals('someTransactionCode', 'transactionCode', $this->chargeResponse);
33
        $this->assertAttributeSame($this->date, 'date', $this->chargeResponse);
34
    }
35
36
    /**
37
     * @test
38
     * @depends constructShouldConfigureTheAttributes
39
     */
40
    public function getTransactionCodeShouldReturnTheConfiguredTransactionCode()
41
    {
42
        $this->assertEquals('someTransactionCode', $this->chargeResponse->getTransactionCode());
43
    }
44
45
    /**
46
     * @test
47
     * @depends constructShouldConfigureTheAttributes
48
     */
49
    public function getDateShouldReturnTheConfiredDate()
50
    {
51
        $this->assertSame($this->date, $this->chargeResponse->getDate());
52
    }
53
}
54