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

DirectLinkPaymentResponseTest::ChecksInvalidXml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 3
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\DirectLinkPaymentResponse;
14
15 View Code Duplication
class DirectLinkPaymentResponseTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
16
{
17
18
    /**
19
     * @test
20
     * @expectedException InvalidArgumentException
21
     */
22
    public function CantExistWithoutXmlFile()
23
    {
24
        $paymentResponse = new DirectLinkPaymentResponse('');
0 ignored issues
show
Unused Code introduced by
$paymentResponse is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
    }
26
27
    /** @test */
28
    public function ParametersCanBeRetrieved()
29
    {
30
        $xml = $this->provideXML();
31
32
        $paymentResponse = new DirectLinkPaymentResponse($xml);
33
        $this->assertEquals('123', $paymentResponse->getParam('orderid'));
34
    }
35
36
    /**
37
     * @test
38
     * @expectedException InvalidArgumentException
39
     */
40
    public function RequestIsFilteredFromNonOgoneParameters()
41
    {
42
        $xml = $this->provideXML();
43
44
        $paymentResponse = new DirectLinkPaymentResponse($xml);
45
        $paymentResponse->getParam('unknown_param');
46
    }
47
48
    /**
49
     * @test
50
     * @expectedException InvalidArgumentException
51
     */
52
    public function ChecksInvalidXml()
53
    {
54
        $xml = $this->provideInvalidXML();
55
56
        $paymentResponse = new DirectLinkPaymentResponse($xml);
0 ignored issues
show
Unused Code introduced by
$paymentResponse is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
57
    }
58
59
    /** @test */
60
    public function ChecksStatus()
61
    {
62
        $xml = $this->provideXML();
63
64
        $paymentResponse = new DirectLinkPaymentResponse($xml);
65
        $this->assertTrue($paymentResponse->isSuccessful());
66
    }
67
68
    /** @test */
69
    public function AmountIsConvertedToCent()
70
    {
71
        $xml = $this->provideXML();
72
73
        $paymentResponse = new DirectLinkPaymentResponse($xml);
74
        $this->assertEquals(100, $paymentResponse->getParam('amount'));
75
    }
76
77
    public function provideFloats()
78
    {
79
        return array(
80
            array('17.89', 1789),
81
            array('65.35', 6535),
82
            array('12.99', 1299),
83
        );
84
    }
85
86
    /**
87
     * @test
88
     * @dataProvider provideFloats
89
     */
90
    public function CorrectlyConvertsFloatAmountsToInteger($string, $integer)
91
    {
92
        $xml = $this->provideXML($string);
93
94
        $paymentResponse = new DirectLinkPaymentResponse($xml);
95
        $this->assertEquals($integer, $paymentResponse->getParam('amount'));
96
    }
97
98
    /**
99
     * Helper method to setup an xml-string
100
     */
101
    private function provideXML($amount = null)
102
    {
103
104
        $xml = '<?xml version="1.0"?>
105
                <ncresponse
106
107
                ORDERID="123"
108
                PAYID="0"
109
                NCSTATUS="5"
110
                NCERROR=""
111
                ACCEPTANCE=""
112
                STATUS="5"
113
                AMOUNT="'.(($amount) ? $amount : '1').'"
114
                CURRENCY="EUR"
115
                PM=""
116
                BRAND=""
117
                NCERRORPLUS="">
118
                </ncresponse>';
119
120
        return $xml;
121
    }
122
123
    /**
124
     * Helper method to setup an invalid xml-string
125
     */
126
    private function provideInvalidXML()
127
    {
128
        $xml = '<?xml version="1.0"?>
129
                <ncresponse
130
                </ncresponse>';
131
132
        return $xml;
133
    }
134
}
135