forked from iisisrael/FOSOAuthServerBundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFOSOAuthServerBundleTest.php
78 lines (66 loc) · 2.3 KB
/
FOSOAuthServerBundleTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
declare(strict_types=1);
/*
* This file is part of the FOSOAuthServerBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\OAuthServerBundle\Tests;
use FOS\OAuthServerBundle\DependencyInjection\Compiler;
use FOS\OAuthServerBundle\DependencyInjection\Security\Factory\OAuthFactory;
use FOS\OAuthServerBundle\FOSOAuthServerBundle;
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class FOSOAuthServerBundleTest extends \PHPUnit\Framework\TestCase
{
protected function setUp(): void
{
parent::setUp();
}
public function testConstruction(): void
{
$bundle = new FOSOAuthServerBundle();
/** @var ContainerBuilder|\PHPUnit\Framework\MockObject\MockObject $containerBuilder */
$containerBuilder = $this->getMockBuilder(ContainerBuilder::class)
->disableOriginalConstructor()
->setMethods([
'getExtension',
'addCompilerPass',
])
->getMock()
;
/** @var SecurityExtension|\PHPUnit\Framework\MockObject\MockObject $securityExtension */
$securityExtension = $this->getMockBuilder(SecurityExtension::class)
->disableOriginalConstructor()
->getMock()
;
$containerBuilder
->expects($this->at(0))
->method('getExtension')
->with('security')
->willReturn($securityExtension)
;
$securityExtension
->expects($this->at(0))
->method('addSecurityListenerFactory')
->with(new OAuthFactory())
->willReturn(null)
;
$containerBuilder
->expects($this->at(1))
->method('addCompilerPass')
->withConsecutive(
new Compiler\GrantExtensionsCompilerPass(),
new Compiler\RequestStackCompilerPass()
)
->willReturnOnConsecutiveCalls(
$containerBuilder,
$containerBuilder
)
;
$this->assertNull($bundle->build($containerBuilder));
}
}