Completed
Push — 1.0-bc-promise ( 0756fc )
by Kamil
51:17 queued 21:58
created

PaymentMethodFixtureTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 4
dl 0
loc 81
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A payment_methods_are_optional() 0 4 1
A payment_methods_can_be_generated_randomly() 0 5 1
A payment_method_code_is_optional() 0 4 1
A payment_method_gateway_name_is_optional() 0 4 1
A payment_method_gateway_factory_is_optional() 0 4 1
A payment_method_gateway_configuration_is_optional() 0 4 1
A payment_method_gateway_configuration_must_by_array() 0 5 1
A payment_method_may_be_toggled() 0 4 1
A getConfiguration() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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
declare(strict_types=1);
13
14
namespace Sylius\Bundle\CoreBundle\Tests\Fixture;
15
16
use Doctrine\Common\Persistence\ObjectManager;
17
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
18
use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;
19
use Sylius\Bundle\CoreBundle\Fixture\PaymentMethodFixture;
20
21
final class PaymentMethodFixtureTest extends \PHPUnit_Framework_TestCase
22
{
23
    use ConfigurationTestCaseTrait;
24
25
    /**
26
     * @test
27
     */
28
    public function payment_methods_are_optional(): void
29
    {
30
        $this->assertConfigurationIsValid([[]], 'custom');
31
    }
32
33
    /**
34
     * @test
35
     */
36
    public function payment_methods_can_be_generated_randomly(): void
37
    {
38
        $this->assertConfigurationIsValid([['random' => 4]], 'random');
39
        $this->assertPartialConfigurationIsInvalid([['random' => -1]], 'random');
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public function payment_method_code_is_optional(): void
46
    {
47
        $this->assertConfigurationIsValid([['custom' => [['code' => 'CUSTOM']]]], 'custom.*.code');
48
    }
49
50
    /**
51
     * @test
52
     */
53
    public function payment_method_gateway_name_is_optional(): void
54
    {
55
        $this->assertConfigurationIsValid([['custom' => [['gatewayName' => 'Online']]]], 'custom.*.gatewayName');
56
    }
57
58
    /**
59
     * @test
60
     */
61
    public function payment_method_gateway_factory_is_optional(): void
62
    {
63
        $this->assertConfigurationIsValid([['custom' => [['gatewayFactory' => 'offline']]]], 'custom.*.gatewayFactory');
64
    }
65
66
    /**
67
     * @test
68
     */
69
    public function payment_method_gateway_configuration_is_optional(): void
70
    {
71
        $this->assertConfigurationIsValid([['custom' => [['gatewayConfig' => []]]]], 'custom.*.gatewayConfig');
72
    }
73
74
    /**
75
     * @test
76
     */
77
    public function payment_method_gateway_configuration_must_by_array(): void
78
    {
79
        $this->assertConfigurationIsValid([['custom' => [['gatewayConfig' => ['username' => 'USERNAME']]]]], 'custom.*.gatewayConfig');
80
        $this->assertConfigurationIsInvalid([['custom' => [['gatewayConfig' => 'USERNAME']]]], 'Invalid type for path "payment_method.custom.0.gatewayConfig". Expected array, but got string');
81
    }
82
83
    /**
84
     * @test
85
     */
86
    public function payment_method_may_be_toggled(): void
87
    {
88
        $this->assertConfigurationIsValid([['custom' => [['enabled' => false]]]], 'custom.*.enabled');
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    protected function getConfiguration(): PaymentMethodFixture
95
    {
96
        return new PaymentMethodFixture(
97
            $this->getMockBuilder(ObjectManager::class)->getMock(),
98
            $this->getMockBuilder(ExampleFactoryInterface::class)->getMock()
99
        );
100
    }
101
}
102