|
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\AdminApiBundle\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\AdminApiBundle\Fixture\ApiClientFixture; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Łukasz Chruściel <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class OAuthCredentialsFixtureTest extends \PHPUnit_Framework_TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
use ConfigurationTestCaseTrait; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @test |
|
28
|
|
|
*/ |
|
29
|
|
|
public function oauth_credentials_can_be_generated_randomly() |
|
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() |
|
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() |
|
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() |
|
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() |
|
70
|
|
|
{ |
|
71
|
|
|
return new ApiClientFixture( |
|
72
|
|
|
$this->getMockBuilder(ObjectManager::class)->getMock(), |
|
73
|
|
|
$this->getMockBuilder(ExampleFactoryInterface::class)->getMock() |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|