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.

provideInvalidXML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * @author Nicolas Clavaud <[email protected]>
4
 */
5
6
namespace Ogone\Tests\DirectLink;
7
8
use Ogone\DirectLink\DirectLinkMaintenanceResponse;
9
10 View Code Duplication
class DirectLinkMaintenanceResponseTest 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...
11
{
12
13
    /**
14
     * @test
15
     * @expectedException InvalidArgumentException
16
     */
17
    public function CantExistWithoutXmlFile()
18
    {
19
        $maintenanceResponse = new DirectLinkMaintenanceResponse('');
0 ignored issues
show
Unused Code introduced by
$maintenanceResponse 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...
20
    }
21
22
    /** @test */
23
    public function ParametersCanBeRetrieved()
24
    {
25
        $xml = $this->provideXML();
26
27
        $maintenanceResponse = new DirectLinkMaintenanceResponse($xml);
28
        $this->assertEquals('5', $maintenanceResponse->getParam('orderid'));
29
    }
30
31
    /**
32
     * @test
33
     * @expectedException InvalidArgumentException
34
     */
35
    public function RequestIsFilteredFromNonOgoneParameters()
36
    {
37
        $xml = $this->provideXML();
38
39
        $maintenanceResponse = new DirectLinkMaintenanceResponse($xml);
40
        $maintenanceResponse->getParam('unknown_param');
41
    }
42
43
    /**
44
     * @test
45
     * @expectedException InvalidArgumentException
46
     */
47
    public function ChecksInvalidXml()
48
    {
49
        $xml = $this->provideInvalidXML();
50
51
        $maintenanceResponse = new DirectLinkMaintenanceResponse($xml);
0 ignored issues
show
Unused Code introduced by
$maintenanceResponse 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...
52
    }
53
54
    /** @test */
55
    public function ChecksStatus()
56
    {
57
        $xml = $this->provideXML();
58
59
        $maintenanceResponse = new DirectLinkMaintenanceResponse($xml);
60
        $this->assertTrue($maintenanceResponse->isSuccessful());
61
    }
62
63
    /** @test */
64
    public function AmountIsConvertedToCent()
65
    {
66
        $xml = $this->provideXML();
67
68
        $maintenanceResponse = new DirectLinkMaintenanceResponse($xml);
69
        $this->assertEquals(100, $maintenanceResponse->getParam('amount'));
70
    }
71
72
    public function provideFloats()
73
    {
74
        return array(
75
            array('17.89', 1789),
76
            array('65.35', 6535),
77
            array('12.99', 1299),
78
        );
79
    }
80
81
    /**
82
     * @test
83
     * @dataProvider provideFloats
84
     */
85
    public function CorrectlyConvertsFloatAmountsToInteger($string, $integer)
86
    {
87
        $xml = $this->provideXML($string);
88
89
        $maintenanceResponse = new DirectLinkMaintenanceResponse($xml);
90
        $this->assertEquals($integer, $maintenanceResponse->getParam('amount'));
91
    }
92
93
    /**
94
     * Helper method to setup an xml-string
95
     */
96
    private function provideXML($amount = null)
97
    {
98
99
        $xml = '<?xml version="1.0"?>
100
                <ncresponse
101
                orderID="5"
102
                PAYID="33146134"
103
                NCERROR="0"
104
                NCERRORPLUS="!"
105
                ACCEPTANCE=""
106
                STATUS="91"
107
                AMOUNT="'.(($amount) ? $amount : '1').'"
108
                CURRENCY="GBP">
109
                </ncresponse>';
110
111
        return $xml;
112
    }
113
114
    /**
115
     * Helper method to setup an invalid xml-string
116
     */
117
    private function provideInvalidXML()
118
    {
119
        $xml = '<?xml version="1.0"?>
120
                <ncresponse
121
                </ncresponse>';
122
123
        return $xml;
124
    }
125
}
126