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
04:52
created

provideBadParameters()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 40
rs 8.8571
cc 1
eloc 33
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Marlon Ogone package.
5
 *
6
 * (c) Marlon BVBA <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ogone\Tests\Ecommerce;
13
14
use Ogone\Tests\ShaComposer\FakeShaComposer;
15
use Ogone\Ecommerce\EcommercePaymentRequest;
16
use Ogone\Tests\TestCase;
17
18
class EcommercePaymentRequestTest extends TestCase
19
{
20
    /** @test */
21
    public function IsValidWhenRequiredFieldsAreFilledIn()
22
    {
23
        $paymentRequest = $this->provideMinimalPaymentRequest();
24
        $paymentRequest->validate();
25
    }
26
27
    /** @test */
28
    public function IsValidWhenAllFieldsAreFilledIn()
29
    {
30
        $paymentRequest = $this->provideCompletePaymentRequest();
31
        $paymentRequest->validate();
32
    }
33
34
    /**
35
     * @test
36
     * @expectedException \RuntimeException
37
     */
38
    public function IsInvalidWhenFieldsAreMissing()
39
    {
40
        $paymentRequest = new EcommercePaymentRequest(new FakeShaComposer);
41
        $paymentRequest->validate();
42
    }
43
44
    /** @test */
45
    public function UnimportantParamsUseMagicSetters()
46
    {
47
        $paymentRequest = new EcommercePaymentRequest(new FakeShaComposer);
48
        $paymentRequest->setBgcolor('FFFFFF');
0 ignored issues
show
Documentation Bug introduced by
The method setBgcolor does not exist on object<Ogone\Ecommerce\EcommercePaymentRequest>? 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...
49
        $this->assertEquals('FFFFFF', $paymentRequest->getBgcolor());
0 ignored issues
show
Documentation Bug introduced by
The method getBgcolor does not exist on object<Ogone\Ecommerce\EcommercePaymentRequest>? 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...
50
    }
51
52
    /**
53
     * @test
54
     * @dataProvider provideBadParameters
55
     * @expectedException \InvalidArgumentException
56
     */
57
    public function BadParametersCauseExceptions($method, $value)
58
    {
59
        $paymentRequest = new EcommercePaymentRequest(new FakeShaComposer);
60
        $paymentRequest->$method($value);
61
    }
62
63
    /**
64
     * @test
65
     * @expectedException \BadMethodCallException
66
     */
67
    public function UnknownMethodFails()
68
    {
69
        $paymentRequest = new EcommercePaymentRequest(new FakeShaComposer);
70
        $paymentRequest->getFoobar();
0 ignored issues
show
Documentation Bug introduced by
The method getFoobar does not exist on object<Ogone\Ecommerce\EcommercePaymentRequest>? 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...
71
    }
72
73
    public function provideBadParameters()
74
    {
75
        $longString = str_repeat('longstring', 100);
76
        $notAUri = 'http://not a uri';
77
        $longUri = "http://www.example.com/$longString";
78
79
        return array(
80
            array('setAccepturl', $notAUri),
81
            array('setAmount', 10.50),
82
            array('setAmount', -1),
83
            array('setAmount', 1000000000000000),
84
            array('setBrand', 'Oxfam'),
85
            array('setCancelurl', $notAUri),
86
            array('setCancelurl', $longUri),
87
            array('setCurrency', 'Belgische Frank'),
88
            //array('setCustomername', ''),
0 ignored issues
show
Unused Code Comprehensibility introduced by
88% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
89
            array('setDeclineurl', $notAUri),
90
            array('setDynamicTemplateUri', $notAUri),
91
            array('setEmail', 'foo @ bar'),
92
            array('setEmail', "[email protected]"),
93
            array('setExceptionurl', $notAUri),
94
            //array('setFeedbackMessage', ''),
0 ignored issues
show
Unused Code Comprehensibility introduced by
88% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
95
            //array('setFeedbackParams', ''),
0 ignored issues
show
Unused Code Comprehensibility introduced by
88% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
96
            array('setLanguage', 'West-Vlaams'),
97
            array('setOgoneUri', $notAUri),
98
            array('setOrderDescription', $longString),
99
            array('setOrderid', "Weird çh@®a©†€rs"),
100
            array('setOrderid', $longString),
101
            array('setOwnerAddress', $longString),
102
            array('setOwnercountry', 'Benidorm'),
103
            array('setOwnerPhone', $longString),
104
            array('setOwnerTown', $longString),
105
            array('setOwnerZip', $longString),
106
            array('setParamvar', $longString),
107
            array('setPaymentMethod', 'Digital'),
108
            array('setPspid', $longString),
109
            array('setOperation', 'UNKNOWN_OPERATION'),
110
            array('setOperation', EcommercePaymentRequest::OPERATION_REFUND),
111
        );
112
    }
113
114
    /** @return EcommercePaymentRequest */
115
    private function provideCompletePaymentRequest()
116
    {
117
        $paymentRequest = $this->provideMinimalPaymentRequest();
118
119
        $paymentRequest->setAccepturl('http://example.com/accept');
120
        $paymentRequest->setDeclineurl('http://example.com/decline');
121
        $paymentRequest->setExceptionurl('http://example.com/exception');
122
        $paymentRequest->setCancelurl('http://example.com/cancel');
123
        $paymentRequest->setBackurl('http://example.com/back');
124
        $paymentRequest->setDynamicTemplateUri('http://example.com/template');
125
126
        $paymentRequest->setCurrency('EUR');
127
        $paymentRequest->setLanguage('nl_BE');
128
        $paymentRequest->setPaymentMethod('CreditCard');
129
        $paymentRequest->setBrand('VISA');
130
131
        $paymentRequest->setFeedbackMessage("Thanks for ordering");
132
        $paymentRequest->setFeedbackParams(array('amountOfProducts' => '5', 'usedCoupon' => 1));
133
        $paymentRequest->setParamvar('aParamVar');
134
        $paymentRequest->setOrderDescription("Four horses and a carriage");
135
136
        $paymentRequest->setOwnerPhone('123456789');
137
138
        $paymentRequest->setOperation(EcommercePaymentRequest::OPERATION_REQUEST_DIRECT_SALE);
139
140
        return $paymentRequest;
141
    }
142
}
143