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 PHPUnit\Framework\TestCase; |
19
|
|
|
use Sylius\Bundle\AdminApiBundle\Fixture\ApiClientFixture; |
20
|
|
|
use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface; |
21
|
|
|
|
22
|
|
|
final class ApiClientFixtureTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
use ConfigurationTestCaseTrait; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @test |
28
|
|
|
*/ |
29
|
|
|
public function oauth_credentials_can_be_generated_randomly(): void |
30
|
|
|
{ |
31
|
|
|
$this->assertConfigurationIsValid([['random' => 4]], 'random'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @test |
36
|
|
|
*/ |
37
|
|
|
public function oauth_credentials_can_be_created_with_custom_random_id(): void |
38
|
|
|
{ |
39
|
|
|
$this->assertConfigurationIsValid([['custom' => [[ |
40
|
|
|
'random_id' => 'totally_random', |
41
|
|
|
]]]], 'custom.*.random_id'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @test |
46
|
|
|
*/ |
47
|
|
|
public function oauth_credentials_can_be_created_with_custom_secret(): void |
48
|
|
|
{ |
49
|
|
|
$this->assertConfigurationIsValid([['custom' => [[ |
50
|
|
|
'secret' => 'threeCanKeepSecretIfTwoAreDead', |
51
|
|
|
]]]], 'custom.*.secret'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @test |
56
|
|
|
*/ |
57
|
|
|
public function oauth_credentials_can_be_created_with_grant_type(): void |
58
|
|
|
{ |
59
|
|
|
$this->assertConfigurationIsValid([['custom' => [[ |
60
|
|
|
'allowed_grant_types' => [ |
61
|
|
|
'password', |
62
|
|
|
], |
63
|
|
|
]]]], 'custom.*.allowed_grant_types'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
*/ |
69
|
|
|
protected function getConfiguration(): ApiClientFixture |
70
|
|
|
{ |
71
|
|
|
return new ApiClientFixture( |
72
|
|
|
$this->getMockBuilder(ObjectManager::class)->getMock(), |
73
|
|
|
$this->getMockBuilder(ExampleFactoryInterface::class)->getMock() |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|