Completed
Push — master ( 9f1cb3...cf412b )
by Kamil
24:31
created

payment_methods_are_optional()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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