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