Passed
Branch master (7fc895)
by João Felipe Magro
03:00
created

SubscriptionTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
dl 0
loc 82
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetTrialCycleShouldThrowUnexpectedValueException() 0 4 1
A testSetStartShouldThrowUnexpectedValueException() 0 4 1
A testSetTrialFrequencyShouldThrowUnexpectedValueException() 0 4 1
A testCreateAndSetSubscriptionSuccessfully() 0 23 1
A setUp() 0 5 1
A testSetAmountShouldThrowUnexpectedValueException() 0 4 1
A testSetProfileIdShouldThrowUnexpectedValueException() 0 4 1
A testSetFrequencyShouldThrowUnexpectedValueException() 0 4 1
A testSetCycleShouldThrowUnexpectedValueException() 0 4 1
A testSetIntervalShouldThrowUnexpectedValueException() 0 4 1
1
<?php
2
3
namespace Tests\Classes;
4
5
use PHPUnit\Framework\TestCase;
6
7
class SubscriptionTest extends TestCase
8
{
9
    private $subscription;
10
11
    public function setUp()
12
    {
13
        parent::setUp();
14
15
        $this->subscription = new \Ipag\Classes\Subscription();
16
    }
17
18
    public function testCreateAndSetSubscriptionSuccessfully()
19
    {
20
        $this->subscription->setProfileId('100000')
21
            ->setFrequency(2)
22
            ->setInterval('month')
23
            ->setCycle(12)
24
            ->setAmount(39.99)
25
            ->setStart('10/10/2018')
26
            ->setTrial(false)
27
            ->setTrialCycle(3)
28
            ->setTrialFrequency(1)
29
            ->setTrialAmount(19.99);
30
31
        $this->assertEquals('100000', $this->subscription->getProfileId());
32
        $this->assertEquals(2, $this->subscription->getFrequency());
33
        $this->assertEquals('month', $this->subscription->getInterval());
34
        $this->assertEquals(12, $this->subscription->getCycle());
35
        $this->assertEquals(39.99, $this->subscription->getAmount());
36
        $this->assertEquals('10/10/2018', $this->subscription->getStart());
37
        $this->assertEquals(false, $this->subscription->isTrial());
38
        $this->assertEquals(3, $this->subscription->getTrialCycle());
39
        $this->assertEquals(1, $this->subscription->getTrialFrequency());
40
        $this->assertEquals(19.99, $this->subscription->getTrialAmount());
41
    }
42
43
    public function testSetFrequencyShouldThrowUnexpectedValueException()
44
    {
45
        $this->expectException(\UnexpectedValueException::class);
46
        $this->subscription->setFrequency(100);
47
    }
48
49
    public function testSetTrialFrequencyShouldThrowUnexpectedValueException()
50
    {
51
        $this->expectException(\UnexpectedValueException::class);
52
        $this->subscription->setTrialFrequency(100);
53
    }
54
55
    public function testSetIntervalShouldThrowUnexpectedValueException()
56
    {
57
        $this->expectException(\UnexpectedValueException::class);
58
        $this->subscription->setInterval('20');
59
    }
60
61
    public function testSetCycleShouldThrowUnexpectedValueException()
62
    {
63
        $this->expectException(\UnexpectedValueException::class);
64
        $this->subscription->setCycle(1000);
65
    }
66
67
    public function testSetTrialCycleShouldThrowUnexpectedValueException()
68
    {
69
        $this->expectException(\UnexpectedValueException::class);
70
        $this->subscription->setTrialCycle(1000);
71
    }
72
73
    public function testSetProfileIdShouldThrowUnexpectedValueException()
74
    {
75
        $this->expectException(\UnexpectedValueException::class);
76
        $this->subscription->setProfileId('ABDCD');
77
    }
78
79
    public function testSetStartShouldThrowUnexpectedValueException()
80
    {
81
        $this->expectException(\UnexpectedValueException::class);
82
        $this->subscription->setStart('2018-10-10');
83
    }
84
85
    public function testSetAmountShouldThrowUnexpectedValueException()
86
    {
87
        $this->expectException(\UnexpectedValueException::class);
88
        $this->subscription->setAmount('ABDC');
89
    }
90
}
91