Completed
Push — pull-request/8715 ( 14a000 )
by Kamil
29:06
created

OAuthCredentialsFixtureTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A oauth_credentials_can_be_generated_randomly() 0 4 1
A oauth_credentials_can_be_created_with_custom_random_id() 0 6 1
A oauth_credentials_can_be_created_with_custom_secret() 0 6 1
A oauth_credentials_can_be_created_with_grant_type() 0 8 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\AdminApiBundle\Tests\Fixture;
15
16
use Doctrine\Common\Persistence\ObjectManager;
17
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
18
use Sylius\Bundle\AdminApiBundle\Fixture\ApiClientFixture;
19
use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;
20
21
/**
22
 * @author Łukasz Chruściel <[email protected]>
23
 */
24
class OAuthCredentialsFixtureTest extends \PHPUnit_Framework_TestCase
25
{
26
    use ConfigurationTestCaseTrait;
27
28
    /**
29
     * @test
30
     */
31
    public function oauth_credentials_can_be_generated_randomly(): void
32
    {
33
        $this->assertConfigurationIsValid([['random' => 4]], 'random');
34
    }
35
36
    /**
37
     * @test
38
     */
39
    public function oauth_credentials_can_be_created_with_custom_random_id(): void
40
    {
41
        $this->assertConfigurationIsValid([['custom' => [[
42
            'random_id' => 'totally_random',
43
        ]]]], 'custom.*.random_id');
44
    }
45
46
    /**
47
     * @test
48
     */
49
    public function oauth_credentials_can_be_created_with_custom_secret(): void
50
    {
51
        $this->assertConfigurationIsValid([['custom' => [[
52
            'secret' => 'threeCanKeepSecretIfTwoAreDead',
53
        ]]]], 'custom.*.secret');
54
    }
55
56
    /**
57
     * @test
58
     */
59
    public function oauth_credentials_can_be_created_with_grant_type(): void
60
    {
61
        $this->assertConfigurationIsValid([['custom' => [[
62
            'allowed_grant_types' => [
63
                'password',
64
            ],
65
        ]]]], 'custom.*.allowed_grant_types');
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    protected function getConfiguration(): ApiClientFixture
72
    {
73
        return new ApiClientFixture(
74
            $this->getMockBuilder(ObjectManager::class)->getMock(),
75
            $this->getMockBuilder(ExampleFactoryInterface::class)->getMock()
76
        );
77
    }
78
}
79