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.

provideMinimalDirectLinkPaymentRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\DirectLink\PaymentOperation;
14
use Ogone\Tests;
15
use Ogone\Tests\ShaComposer\FakeShaComposer;
16
use Ogone\DirectLink\DirectLinkPaymentRequest;
17
use Ogone\DirectLink\Alias;
18
19
class DirectLinkPaymentRequestTest extends \PHPUnit_Framework_TestCase
20
{
21
22
    /** @test */
23
    public function IsValidWhenRequiredFieldsAreFilledIn()
24
    {
25
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
26
        $directLinkPaymentRequest->validate();
27
    }
28
29
    /**
30
     * @test
31
     * @expectedException \RuntimeException
32
     */
33
    public function IsInvalidWhenFieldsAreMissing()
34
    {
35
        $directLinkPaymentRequest = new DirectLinkPaymentRequest(new FakeShaComposer);
36
        $directLinkPaymentRequest->validate();
37
    }
38
39
    /**
40
     * @test
41
     * @expectedException \InvalidArgumentException
42
     */
43
    public function isInvalidWithNonOgoneUrl()
44
    {
45
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
46
        $directLinkPaymentRequest->setOgoneUri('http://example.com');
47
        $directLinkPaymentRequest->validate();
48
    }
49
50
    /**
51
     * @test
52
     */
53
    public function isValidWithOgoneUrl()
54
    {
55
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
56
        $directLinkPaymentRequest->setOgoneUri(DirectLinkPaymentRequest::PRODUCTION);
57
        $directLinkPaymentRequest->validate();
58
    }
59
60
    /**
61
     * @test
62
     */
63
    public function isValidWhenAliasSet()
64
    {
65
        $alias = new Alias('customer_123');
66
67
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
68
        $directLinkPaymentRequest->setAlias($alias);
69
        $directLinkPaymentRequest->validate();
70
    }
71
72
    /**
73
     * @test
74
     * @expectedException \InvalidArgumentException
75
     */
76 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...
77
    {
78
        $alias = new Alias(str_repeat('repeat', 10));
79
80
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
81
        $directLinkPaymentRequest->setAlias($alias);
82
        $directLinkPaymentRequest->validate();
83
    }
84
85
    /**
86
     * @test
87
     */
88
    public function isValidWhenOperationIsSet()
89
    {
90
        $directLinkPaymentRequest = $this->provideMinimalDirectLinkPaymentRequest();
91
        $directLinkPaymentRequest->setOperation(new PaymentOperation(PaymentOperation::REQUEST_FOR_DIRECT_SALE));
92
        $directLinkPaymentRequest->validate();
93
    }
94
95
    /**
96
     * @test
97
     * @dataProvider provideBadParameters
98
     * @expectedException \InvalidArgumentException
99
     */
100
    public function BadParametersCauseExceptions($method, $value)
101
    {
102
        $directLinkPaymentRequest = new DirectLinkPaymentRequest(new FakeShaComposer);
103
        $directLinkPaymentRequest->$method($value);
104
    }
105
106
    public function provideBadParameters()
107
    {
108
        return array(
109
            array('setPswd', '12'),
110
            array('setUserid', '1'),
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