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.

createSubscriptionRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Ogone\Tests\Subscription;
4
5
use Ogone\Subscription\SubscriptionPaymentRequest;
6
use Ogone\Subscription\SubscriptionPeriod;
7
use Ogone\Tests\ShaComposer\FakeShaComposer;
8
9
class SubscriptionPaymentRequestTest extends \PHPUnit_Framework_TestCase
10
{
11
12
    /** @test */
13
    public function AmountCanBeZero()
14
    {
15
        $paymentRequest = $this->createSubscriptionRequest();
16
        $paymentRequest->setAmount(0);
17
        $this->assertEquals(0, $paymentRequest->getAmount());
0 ignored issues
show
Documentation Bug introduced by
The method getAmount does not exist on object<Ogone\Subscriptio...criptionPaymentRequest>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
18
    }
19
20
    /**
21
     * @test
22
     * @dataProvider provideBadParameters
23
     * @expectedException \InvalidArgumentException
24
     */
25
    public function BadParametersCauseExceptions($method, $value)
26
    {
27
        $paymentRequest = $this->createSubscriptionRequest();
28
        $paymentRequest->$method($value);
29
    }
30
31
    /**
32
     * @test
33
     * @expectedException \RuntimeException
34
     */
35
    public function IsInvalidIfSubscriptionParametersAreMissing()
36
    {
37
        $paymentRequest = $this->createSubscriptionRequest();
38
        $paymentRequest->setPspid('12');
39
        $paymentRequest->setCurrency('EUR');
40
        $paymentRequest->setAmount(0);
41
        $paymentRequest->setOrderId('10');
42
        $paymentRequest->validate();
43
    }
44
45
    /** @test */
46
    public function RequestCanBeValid()
47
    {
48
        $paymentRequest = $this->createSubscriptionRequest();
49
        $paymentRequest->setPspid('12');
50
        $paymentRequest->setCurrency('EUR');
51
        $paymentRequest->setAmount(0);
52
        $paymentRequest->setOrderId('10');
53
        $paymentRequest->setSubscriptionId('12');
54
        $paymentRequest->setSubscriptionAmount(13);
55
        $paymentRequest->setSubscriptionComment('test');
56
        $paymentRequest->setSubscriptionDescription('description');
57
        $paymentRequest->setSubscriptionOrderId('13');
58
        $paymentRequest->setSubscriptionPeriod($this->createSubscriptionPeriod());
59
        $paymentRequest->setSubscriptionStartdate(new \DateTime());
60
        $paymentRequest->setSubscriptionEnddate(new \DateTime());
61
        $paymentRequest->setSubscriptionStatus(1);
62
        $paymentRequest->validate();
63
        $this->assertTrue(true);
64
    }
65
66
    public function provideBadParameters()
67
    {
68
69
        return array(
70
            array('setAmount', 10.50),
71
            array('setAmount', -1),
72
            array('setAmount', 150000000000000000),
73
            array('setSubscriptionId', 'this is a little more than 50 characters, which is truly the max amount'),
74
            array('setSubscriptionId', '$e©ial Ch@r@cters'),
75
            array('setSubscriptionAmount', 10.50),
76
            array('setSubscriptionAmount', 0),
77
            array('setSubscriptionAmount', -1),
78
            array('setSubscriptionAmount', 150000000000000000),
79
            array('setSubscriptionDescription', 'this is a little more than 100 characters- which is truly the maximum amount of characters one can pass as a parameter to this particular function'),
80
            array('setSubscriptionDescription', 'special, characters!'),
81
            array('setSubscriptionOrderId', 'this is a little more than 40 characters- which is truly the max amount'),
82
            array('setSubscriptionOrderId', 'special, characters!'),
83
            array('setSubscriptionStatus', 5),
84
            array('setSubscriptionComment', 'this particular string is supposed to be longer than 200 characters- which will require me to type for quite a while longer than the string that needed to exceed 50 chars- which is- in fact- significantly lower than 200'),
85
            array('setSubscriptionComment', 'special, characters!')
86
        );
87
    }
88
89
    protected function createSubscriptionRequest()
90
    {
91
        return new SubscriptionPaymentRequest(new FakeShaComposer());
92
    }
93
94
    protected function createSubscriptionPeriod()
95
    {
96
        return new SubscriptionPeriod(SubscriptionPeriod::UNIT_DAILY, 12, 7);
97
    }
98
}
99