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

SimpleFormGeneratorTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 85
Duplicated Lines 61.18 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 10
Bugs 2 Features 2
Metric Value
wmc 3
c 10
b 2
f 2
lcom 1
cbo 3
dl 52
loc 85
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B GeneratesAForm() 0 25 1
B BCCheck() 25 25 1
B GeneratesAFormWithCustomOperationParameter() 27 27 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\FormGenerator;
13
14
use Ogone\FormGenerator\SimpleFormGenerator;
15
use Ogone\PaymentRequest;
16
use Ogone\Tests\TestCase;
17
18
class SimpleFormGeneratorTest extends TestCase
19
{
20
    /** @test */
21
    public function GeneratesAForm()
22
    {
23
        $expected =
24
            '<form method="post" action="https://secure.ogone.com/ncol/test/orderstandard_utf8.asp" id="ogone" name="ogone">
25
                <input type="hidden" name="PSPID" value="123456789" />
26
                <input type="hidden" name="ORDERID" value="987654321" />
27
                <input type="hidden" name="CURRENCY" value="EUR" />
28
                <input type="hidden" name="AMOUNT" value="100" />
29
                <input type="hidden" name="CN" value="Louis XIV" />
30
                <input type="hidden" name="OWNERADDRESS" value="1, Rue du Palais" />
31
                <input type="hidden" name="OWNERTOWN" value="Versailles" />
32
                <input type="hidden" name="OWNERZIP" value="2300" />
33
                <input type="hidden" name="OWNERCTY" value="FR" />
34
                <input type="hidden" name="EMAIL" value="[email protected]" />
35
                <input type="hidden" name="'.PaymentRequest::SHASIGN_FIELD.'" value="foo" />
36
                <input type="submit" value="Submit" id="ogonesubmit" name="ogonesubmit" />
37
            </form>';
38
39
        $paymentRequest = $this->provideMinimalPaymentRequest();
40
41
        $formGenerator = new SimpleFormGenerator();
42
43
        $this->assertXmlStringEqualsXmlString($expected, $formGenerator->render($paymentRequest));
44
        $this->assertXmlStringEqualsXmlString($expected, $formGenerator->render($paymentRequest, 'ogone', true));
45
    }
46
47
    /** @test */
48 View Code Duplication
    public function BCCheck()
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...
49
    {
50
        $expected =
51
            '<form method="post" action="https://secure.ogone.com/ncol/test/orderstandard_utf8.asp" id="ogoneform" name="ogoneform">
52
                <input type="hidden" name="PSPID" value="123456789" />
53
                <input type="hidden" name="ORDERID" value="987654321" />
54
                <input type="hidden" name="CURRENCY" value="EUR" />
55
                <input type="hidden" name="AMOUNT" value="100" />
56
                <input type="hidden" name="CN" value="Louis XIV" />
57
                <input type="hidden" name="OWNERADDRESS" value="1, Rue du Palais" />
58
                <input type="hidden" name="OWNERTOWN" value="Versailles" />
59
                <input type="hidden" name="OWNERZIP" value="2300" />
60
                <input type="hidden" name="OWNERCTY" value="FR" />
61
                <input type="hidden" name="EMAIL" value="[email protected]" />
62
                <input type="hidden" name="'.PaymentRequest::SHASIGN_FIELD.'" value="foo" />
63
            </form>';
64
65
        $paymentRequest = $this->provideMinimalPaymentRequest();
66
67
        $formGenerator = new SimpleFormGenerator();
68
        $formGenerator->setFormName('ogoneform');
0 ignored issues
show
Deprecated Code introduced by
The method Ogone\FormGenerator\Simp...enerator::setFormName() has been deprecated with message: Will be removed in next major released, directly integrated in render method.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
69
        $formGenerator->showSubmitButton(false);
0 ignored issues
show
Deprecated Code introduced by
The method Ogone\FormGenerator\Simp...tor::showSubmitButton() has been deprecated with message: Will be removed in next major released, directly integrated in render method.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
70
        $this->assertXmlStringEqualsXmlString($expected, $formGenerator->render($paymentRequest));
71
        $this->assertXmlStringEqualsXmlString($expected, $formGenerator->render($paymentRequest, 'ogoneform', false));
72
    }
73
74
	/** @test */
75 View Code Duplication
	public function GeneratesAFormWithCustomOperationParameter()
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
        $expected =
78
            '<form method="post" action="https://secure.ogone.com/ncol/test/orderstandard_utf8.asp" id="ogone" name="ogone">
79
                <input type="hidden" name="PSPID" value="123456789" />
80
                <input type="hidden" name="ORDERID" value="987654321" />
81
                <input type="hidden" name="CURRENCY" value="EUR" />
82
                <input type="hidden" name="AMOUNT" value="100" />
83
                <input type="hidden" name="CN" value="Louis XIV" />
84
                <input type="hidden" name="OWNERADDRESS" value="1, Rue du Palais" />
85
                <input type="hidden" name="OWNERTOWN" value="Versailles" />
86
                <input type="hidden" name="OWNERZIP" value="2300" />
87
                <input type="hidden" name="OWNERCTY" value="FR" />
88
                <input type="hidden" name="EMAIL" value="[email protected]" />
89
                <input type="hidden" name="OPERATION" value="SAL" />
90
                <input type="hidden" name="'.PaymentRequest::SHASIGN_FIELD.'" value="foo" />
91
                <input type="submit" value="Submit" id="ogonesubmit" name="ogonesubmit" />
92
            </form>';
93
94
        $paymentRequest = $this->provideMinimalPaymentRequest();
95
        $paymentRequest->setOperation('SAL');
96
97
        $formGenerator = new SimpleFormGenerator();
98
99
        $this->assertXmlStringEqualsXmlString($expected, $formGenerator->render($paymentRequest));
100
        $this->assertXmlStringEqualsXmlString($expected, $formGenerator->render($paymentRequest, 'ogone', true));
101
	}
102
}
103