shouldAllowCreateGatewayConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace PTS\Paysera\Tests;
5
6
use Payum\Core\Exception\LogicException;
7
use Payum\Core\Gateway;
8
use Payum\Core\GatewayFactoryInterface;
9
use PHPUnit\Framework\TestCase;
10
use PTS\Paysera\PayseraGatewayFactory;
11
12
class PayseraGatewayFactoryTest extends TestCase
13
{
14
    /**
15
     * @test
16
     */
17
    public function shouldImplementGatewayFactoryInterface()
18
    {
19
        $rc = new \ReflectionClass(PayseraGatewayFactory::class);
20
        $this->assertTrue($rc->implementsInterface(GatewayFactoryInterface::class));
21
    }
22
23
    /**
24
     * @test
25
     */
26
    public function couldBeConstructedWithoutAnyArguments()
27
    {
28
        $this->expectNotToPerformAssertions();
29
        new PayseraGatewayFactory();
30
    }
31
32
33
    /**
34
     * @test
35
     */
36
    public function shouldUseCoreGatewayFactoryPassedAsSecondArgument()
37
    {
38
        $coreGatewayFactory = $this->createMock('Payum\Core\GatewayFactoryInterface');
39
        $factory = new PayseraGatewayFactory([], $coreGatewayFactory);
40
        $this->assertAttributeSame($coreGatewayFactory, 'coreGatewayFactory', $factory);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertAttributeSame() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

40
        /** @scrutinizer ignore-deprecated */ $this->assertAttributeSame($coreGatewayFactory, 'coreGatewayFactory', $factory);

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

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

Loading history...
41
    }
42
43
    /**
44
     * @test
45
     */
46
    public function shouldAllowCreateGateway()
47
    {
48
        $factory = new PayseraGatewayFactory();
49
        $gateway = $factory->create([
50
            'projectid' => 'testProjectId',
51
            'sign_password' => 'testSignPassword'
52
        ]);
53
        $this->assertInstanceOf(Gateway::class, $gateway);
54
        $this->assertAttributeNotEmpty('apis', $gateway);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert...sertAttributeNotEmpty() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

54
        /** @scrutinizer ignore-deprecated */ $this->assertAttributeNotEmpty('apis', $gateway);

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

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

Loading history...
55
        $this->assertAttributeNotEmpty('actions', $gateway);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert...sertAttributeNotEmpty() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
        /** @scrutinizer ignore-deprecated */ $this->assertAttributeNotEmpty('actions', $gateway);

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

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

Loading history...
56
        $extensions = $this->readAttribute($gateway, 'extensions');
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::readAttribute() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

56
        $extensions = /** @scrutinizer ignore-deprecated */ $this->readAttribute($gateway, 'extensions');

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

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

Loading history...
57
        $this->assertAttributeNotEmpty('extensions', $extensions);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert...sertAttributeNotEmpty() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

57
        /** @scrutinizer ignore-deprecated */ $this->assertAttributeNotEmpty('extensions', $extensions);

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

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

Loading history...
58
    }
59
60
    /**
61
     * @test
62
     */
63
    public function shouldAllowCreateGatewayWithCustomApi()
64
    {
65
        $factory = new PayseraGatewayFactory();
66
        $gateway = $factory->create(['payum.api' => new \stdClass()]);
67
        $this->assertInstanceOf(Gateway::class, $gateway);
68
        $this->assertAttributeNotEmpty('apis', $gateway);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert...sertAttributeNotEmpty() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

68
        /** @scrutinizer ignore-deprecated */ $this->assertAttributeNotEmpty('apis', $gateway);

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

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

Loading history...
69
        $this->assertAttributeNotEmpty('actions', $gateway);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert...sertAttributeNotEmpty() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

69
        /** @scrutinizer ignore-deprecated */ $this->assertAttributeNotEmpty('actions', $gateway);

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

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

Loading history...
70
        $extensions = $this->readAttribute($gateway, 'extensions');
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::readAttribute() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

70
        $extensions = /** @scrutinizer ignore-deprecated */ $this->readAttribute($gateway, 'extensions');

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

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

Loading history...
71
        $this->assertAttributeNotEmpty('extensions', $extensions);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert...sertAttributeNotEmpty() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

71
        /** @scrutinizer ignore-deprecated */ $this->assertAttributeNotEmpty('extensions', $extensions);

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

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

Loading history...
72
    }
73
74
    /**
75
     * @test
76
     */
77
    public function shouldAllowCreateGatewayConfig()
78
    {
79
        $factory = new PayseraGatewayFactory();
80
        $config = $factory->createConfig();
81
        $this->assertInternalType('array', $config);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertInternalType() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3369 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

81
        /** @scrutinizer ignore-deprecated */ $this->assertInternalType('array', $config);

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

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

Loading history...
82
        $this->assertNotEmpty($config);
83
    }
84
85
    /**
86
     * @test
87
     */
88
    public function shouldAddDefaultConfigPassedInConstructorWhileCreatingGatewayConfig()
89
    {
90
        $factory = new PayseraGatewayFactory(array(
91
            'foo' => 'fooVal',
92
            'bar' => 'barVal',
93
        ));
94
        $config = $factory->createConfig();
95
        $this->assertInternalType('array', $config);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertInternalType() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3369 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

95
        /** @scrutinizer ignore-deprecated */ $this->assertInternalType('array', $config);

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

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

Loading history...
96
        $this->assertArrayHasKey('foo', $config);
97
        $this->assertEquals('fooVal', $config['foo']);
98
        $this->assertArrayHasKey('bar', $config);
99
        $this->assertEquals('barVal', $config['bar']);
100
    }
101
102
    /**
103
     * @test
104
     */
105
    public function shouldConfigContainDefaultOptions()
106
    {
107
        $factory = new PayseraGatewayFactory();
108
        $config = $factory->createConfig();
109
        $this->assertInternalType('array', $config);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertInternalType() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3369 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

109
        /** @scrutinizer ignore-deprecated */ $this->assertInternalType('array', $config);

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

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

Loading history...
110
        $this->assertArrayHasKey('payum.default_options', $config);
111
        $this->assertArraySubset(
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertArraySubset() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3494 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

111
        /** @scrutinizer ignore-deprecated */ $this->assertArraySubset(

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

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

Loading history...
112
            [
113
                'projectid' => '',
114
                'sign_password' => '',
115
                'test' => true
116
            ],
117
            $config['payum.default_options']
118
        );
119
    }
120
121
    /**
122
     * @test
123
     */
124
    public function shouldConfigContainFactoryNameAndTitle()
125
    {
126
        $factory = new PayseraGatewayFactory();
127
        $config = $factory->createConfig();
128
        $this->assertInternalType('array', $config);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertInternalType() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3369 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

128
        /** @scrutinizer ignore-deprecated */ $this->assertInternalType('array', $config);

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

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

Loading history...
129
        $this->assertArrayHasKey('payum.factory_name', $config);
130
        $this->assertEquals('paysera', $config['payum.factory_name']);
131
        $this->assertArrayHasKey('payum.factory_title', $config);
132
        $this->assertEquals('paysera', $config['payum.factory_title']);
133
    }
134
135
    /**
136
     * @test
137
     */
138
    public function shouldThrowIfRequiredOptionsNotPassed()
139
    {
140
        $this->expectException(LogicException::class);
141
        $this->expectExceptionMessage('The projectid, sign_password fields are required.');
142
        $factory = new PayseraGatewayFactory();
143
        $factory->create();
144
    }
145
146
    /**
147
     * @test
148
     */
149
    public function shouldConfigurePaths()
150
    {
151
        $factory = new PayseraGatewayFactory();
152
        $config = $factory->createConfig();
153
        $this->assertInternalType('array', $config);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertInternalType() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3369 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

153
        /** @scrutinizer ignore-deprecated */ $this->assertInternalType('array', $config);

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

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

Loading history...
154
        $this->assertNotEmpty($config);
155
        $this->assertInternalType('array', $config['payum.paths']);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertInternalType() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3369 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

155
        /** @scrutinizer ignore-deprecated */ $this->assertInternalType('array', $config['payum.paths']);

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

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

Loading history...
156
        $this->assertNotEmpty($config['payum.paths']);
157
        $this->assertArrayHasKey('PayumCore', $config['payum.paths']);
158
        $this->assertStringEndsWith('Resources/views', $config['payum.paths']['PayumCore']);
159
        $this->assertTrue(file_exists($config['payum.paths']['PayumCore']));
160
    }
161
}