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.
Completed
Pull Request — master (#62)
by Jelte
03:21
created

BadParametersCauseExceptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/*
3
 * This file is part of the Marlon Ogone package.
4
 *
5
 * (c) Marlon BVBA <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Ogone\Tests\DirectLink;
12
13
use Ogone\Tests;
14
use Ogone\Tests\ShaComposer\FakeShaComposer;
15
use Ogone\DirectLink\DirectLinkPaymentRequest;
16
use Ogone\DirectLink\Alias;
17
18
class DirectLinkPaymentRequestTest extends \PHPUnit_Framework_TestCase
19
{
20
21
    /** @test */
22
    public function IsValidWhenRequiredFieldsAreFilledIn()
23
    {
24
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
25
        $directLinkPaymentRequest->validate();
26
    }
27
28
    /**
29
     * @test
30
     * @expectedException \RuntimeException
31
     */
32
    public function IsInvalidWhenFieldsAreMissing()
33
    {
34
        $directLinkPaymentRequest = new DirectLinkPaymentRequest(new FakeShaComposer);
35
        $directLinkPaymentRequest->validate();
36
    }
37
38
    /**
39
     * @test
40
     * @expectedException \InvalidArgumentException
41
     */
42
    public function isInvalidWithNonOgoneUrl()
43
    {
44
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
45
        $directLinkPaymentRequest->setOgoneUri('http://example.com');
46
        $directLinkPaymentRequest->validate();
47
    }
48
49
    /**
50
     * @test
51
     */
52
    public function isValidWithOgoneUrl()
53
    {
54
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
55
        $directLinkPaymentRequest->setOgoneUri(DirectLinkPaymentRequest::PRODUCTION);
56
        $directLinkPaymentRequest->validate();
57
    }
58
59
    /**
60
     * @test
61
     */
62
    public function isValidWhenAliasSet()
63
    {
64
        $alias = new Alias('customer_123');
65
66
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
67
        $directLinkPaymentRequest->setAlias($alias);
68
        $directLinkPaymentRequest->validate();
69
    }
70
71
    /**
72
     * @test
73
     * @expectedException \InvalidArgumentException
74
     */
75 View Code Duplication
    public function IsInvalidWithTooLongAlias()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77
        $alias = new Alias(str_repeat('repeat', 10));
78
79
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
80
        $directLinkPaymentRequest->setAlias($alias);
81
        $directLinkPaymentRequest->validate();
82
    }
83
84
    /**
85
     * @test
86
     */
87
    public function isValidWhenOperationIsSet()
88
    {
89
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
90
        $directLinkPaymentRequest->setOperation(DirectLinkPaymentRequest::OPERATION_REQUEST_DIRECT_SALE);
91
        $directLinkPaymentRequest->validate();
92
    }
93
94
    /**
95
     * @test
96
     * @dataProvider provideBadParameters
97
     * @expectedException \InvalidArgumentException
98
     */
99
    public function BadParametersCauseExceptions($method, $value)
100
    {
101
        $directLinkPaymentRequest = new DirectLinkPaymentRequest(new FakeShaComposer);
102
        $directLinkPaymentRequest->$method($value);
103
    }
104
105
    public function provideBadParameters()
106
    {
107
        return array(
108
            array('setPswd', '12'),
109
            array('setUserid', '12'),
110
            array('setOperation', 'UNKNOWN_OPERATION'),
111
        );
112
    }
113
114
    /** @return DirectLinkPaymentRequest */
115
    private function provideMinimalDirectLinkPaymentRequest()
116
    {
117
        $directLinkRequest = new DirectLinkPaymentRequest(new FakeShaComposer());
118
        $directLinkRequest->setPspid('123456');
119
        $directLinkRequest->setUserId('user_1234');
120
        $directLinkRequest->setPassword('abracadabra');
121
        $directLinkRequest->setAmount(100);
122
        $directLinkRequest->setCurrency('EUR');
123
        $directLinkRequest->setOrderid('999');
124
125
        return $directLinkRequest;
126
    }
127
}
128