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\ApiAccessTokenFixture; |
19
|
|
|
use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Łukasz Chruściel <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class ApiAccessTokenFixtureTest extends \PHPUnit_Framework_TestCase |
25
|
|
|
{ |
26
|
|
|
use ConfigurationTestCaseTrait; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @test |
30
|
|
|
*/ |
31
|
|
|
public function access_token_can_be_generated_randomly(): void |
32
|
|
|
{ |
33
|
|
|
$this->assertConfigurationIsValid([['random' => 4]], 'random'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @test |
38
|
|
|
*/ |
39
|
|
|
public function access_token_can_be_created_with_custom_random_id(): void |
40
|
|
|
{ |
41
|
|
|
$this->assertConfigurationIsValid([['custom' => [[ |
42
|
|
|
'client' => 'some_client', |
43
|
|
|
]]]], 'custom.*.client'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @test |
48
|
|
|
*/ |
49
|
|
|
public function access_token_can_be_created_with_custom_secret(): void |
50
|
|
|
{ |
51
|
|
|
$this->assertConfigurationIsValid([['custom' => [[ |
52
|
|
|
'user' => '[email protected]', |
53
|
|
|
]]]], 'custom.*.user'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @test |
58
|
|
|
*/ |
59
|
|
|
public function access_token_can_be_created_with_grant_type(): void |
60
|
|
|
{ |
61
|
|
|
$this->assertConfigurationIsValid([['custom' => [[ |
62
|
|
|
'token' => 'some_token', |
63
|
|
|
]]]], 'custom.*.token'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @test |
68
|
|
|
*/ |
69
|
|
|
public function access_token_can_be_created_with_expires_at(): void |
70
|
|
|
{ |
71
|
|
|
$this->assertConfigurationIsValid([['custom' => [[ |
72
|
|
|
'expires_at' => '7 days', |
73
|
|
|
]]]], 'custom.*.expires_at'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
|
|
protected function getConfiguration(): ApiAccessTokenFixture |
80
|
|
|
{ |
81
|
|
|
return new ApiAccessTokenFixture( |
82
|
|
|
$this->getMockBuilder(ObjectManager::class)->getMock(), |
83
|
|
|
$this->getMockBuilder(ExampleFactoryInterface::class)->getMock() |
84
|
|
|
); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|