Completed
Pull Request — develop (#48)
by Luís
03:01
created

TransactionTest   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 14
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 145
rs 10
1
<?php
2
namespace PHPSC\PagSeguro\Purchases\Transactions;
3
4
use DateTime;
5
use PHPSC\PagSeguro\Shipping\Shipping;
6
use PHPSC\PagSeguro\Purchases\Details;
7
use PHPSC\PagSeguro\Items\ItemCollection;
8
9
/**
10
 * @author Adelar Tiemann Junior <[email protected]>
11
 */
12
class TransactionTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var Transaction
16
     */
17
    private $transaction;
18
       
19
    /**
20
     * @var Details
21
     */
22
    private $details;
23
    
24
    /**
25
     * @var Payment
26
     */
27
    private $payment;
28
    
29
    /**
30
     * @var ItemCollection
31
     */
32
    private $itemCollection;
33
    
34
    /**
35
     * @var Shipping
36
     */
37
    private $shipping;
38
39
    protected function setUp()
40
    {
41
        $this->details        = $this->createMock(Details::class);
42
        $this->payment        = $this->createMock(Payment::class);
43
        $this->itemCollection = $this->createMock(ItemCollection::class);
44
        $this->shipping       = $this->createMock(Shipping::class);
45
        
46
        $this->transaction = new Transaction(
47
            $this->details,
48
            $this->payment,
49
            1,
50
            $this->itemCollection,
51
            $this->shipping
52
        );
53
    }
54
55
    /**
56
     * @test
57
     */
58
    public function constructShouldConfigureTheAttributes()
59
    {
60
        $this->assertAttributeSame($this->details, 'details', $this->transaction);
61
        $this->assertAttributeSame($this->payment, 'payment', $this->transaction);
62
        $this->assertAttributeEquals(1, 'type', $this->transaction);
63
        $this->assertAttributeSame($this->itemCollection, 'items', $this->transaction);
64
        $this->assertAttributeSame($this->shipping, 'shipping', $this->transaction);
65
    }
66
67
    /**
68
     * @test
69
     */
70
    public function getDetailsShouldReturnTheConfiguredDetails()
71
    {
72
        $this->assertSame($this->details, $this->transaction->getDetails());
73
    }
74
75
    /**
76
     * @test
77
     */
78
    public function getTypeShouldReturnTheConfiguredType()
79
    {
80
        $this->assertEquals(1, $this->transaction->getType());
81
    }
82
83
    /**
84
     * @test
85
     */
86
    public function getPaymentShouldReturnTheConfiguredPayment()
87
    {
88
        $this->assertSame($this->payment, $this->transaction->getPayment());
89
    }
90
91
    /**
92
     * @test
93
     */
94
    public function getItemsShouldReturnTheConfiguredItems()
95
    {
96
        $this->assertSame($this->itemCollection, $this->transaction->getItems());
97
    }
98
99
    /**
100
     * @test
101
     */
102
    public function getShippingShouldReturnTheConfiguredShipping()
103
    {
104
        $this->assertSame($this->shipping, $this->transaction->getShipping());
105
    }
106
107
    /**
108
     * @test
109
     */
110
    public function getIsWaitingPaymentShouldReturnTheConfiguredIsWaitingPayment()
111
    {
112
        $this->assertFalse($this->transaction->isWaitingPayment());
113
    }
114
115
    /**
116
     * @test
117
     */
118
    public function getIsUnderAnalysisShouldReturnTheConfiguredIsUnderAnalysis()
119
    {
120
        $this->assertFalse($this->transaction->isUnderAnalysis());
121
    }
122
123
    /**
124
     * @test
125
     */
126
    public function getIsPaidShouldReturnTheConfiguredIsPaid()
127
    {
128
        $this->assertFalse($this->transaction->isPaid());
129
    }
130
131
    /**
132
     * @test
133
     */
134
    public function getIsAvailableShouldReturnTheConfiguredIsAvailable()
135
    {
136
        $this->assertFalse($this->transaction->isAvailable());
137
    }
138
139
    /**
140
     * @test
141
     */
142
    public function getIsUnderContestShouldReturnTheConfiguredIsUnderContest()
143
    {
144
        $this->assertFalse($this->transaction->isUnderContest());
145
    }
146
147
    /**
148
     * @test
149
     */
150
    public function getIsReturnedShouldReturnTheConfiguredIsReturned()
151
    {
152
        $this->assertFalse($this->transaction->isReturned());
153
    }
154
155
    /**
156
     * @test
157
     */
158
    public function getIsCancelledShouldReturnTheConfiguredIsCancelled()
159
    {
160
        $this->assertFalse($this->transaction->isCancelled());
161
    }
162
}
163