File tree Expand file tree Collapse file tree 6 files changed +6
-64
lines changed
Tests/DependencyInjection
Fixtures/Resources/config Expand file tree Collapse file tree 6 files changed +6
-64
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 7
7
<call method =" setReader" >
8
8
<argument type =" service" id =" annotation_reader" />
9
9
</call >
10
+ <argument type =" service" id =" security.authorization_checker" />
10
11
</service >
11
12
<service id =" openclassrooms.use_case.security_factory" class =" OpenClassrooms\Bundle\UseCaseBundle\Services\Security\Impl\SecurityFactoryImpl" public =" true" />
12
13
<service id =" openclassrooms.use_case.transaction_factory" class =" OpenClassrooms\Bundle\UseCaseBundle\Services\Transaction\Impl\TransactionFactoryImpl" public =" true" />
Original file line number Diff line number Diff line change @@ -48,7 +48,9 @@ class UseCaseProxyFactoryImpl implements UseCaseProxyFactory
48
48
*/
49
49
private $ builder ;
50
50
51
- public function __construct ()
51
+ public function __construct (
52
+ private readonly AuthorizationCheckerInterface $ authorizationChecker
53
+ )
52
54
{
53
55
$ this ->builder = new UseCaseProxyBuilderImpl ();
54
56
}
@@ -114,15 +116,7 @@ private function buildSecurity(array $tagParameters)
114
116
if (isset ($ tagParameters ['security ' ])) {
115
117
$ security = $ this ->container ->get ($ tagParameters ['security ' ]);
116
118
} else {
117
- $ defaultSecurityContextId = $ this ->container ->getParameter (
118
- 'openclassrooms.use_case.default_authorization_checker '
119
- );
120
- if (!$ this ->container ->has ($ defaultSecurityContextId )) {
121
- throw new SecurityIsNotDefinedException ('Default security context: \'' .$ defaultSecurityContextId .'\' is not defined. ' );
122
- }
123
- $ security = $ this ->container ->get (
124
- $ this ->container ->getParameter ('openclassrooms.use_case.default_authorization_checker ' )
125
- );
119
+ $ security = $ this ->authorizationChecker ;
126
120
}
127
121
if ($ security instanceof AuthorizationCheckerInterface) {
128
122
/** @var SecurityFactory $securityFactory */
Original file line number Diff line number Diff line change 16
16
<parameter key =" openclassrooms.tests.use_cases.event_use_case_stub.class" >OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\EventUseCaseStub</parameter >
17
17
</parameters >
18
18
<services >
19
+ <service id =" security.authorization_checker" class =" OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util\AuthorizationCheckerSpy" />
19
20
<service id =" annotation_reader" class =" Doctrine\Common\Annotations\AnnotationReader" />
20
21
<service id =" openclassrooms.tests.util.security_stub" class =" %openclassrooms.tests.util.security_stub.class%" public =" true" />
21
22
<service id =" openclassrooms.tests.util.authorization_checker_stub" class =" %openclassrooms.tests.util.authorization_checker_stub.class%" public =" true" />
Original file line number Diff line number Diff line change 11
11
*/
12
12
class SecurityOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTestCase
13
13
{
14
- /**
15
- * @test
16
- */
17
- public function WithSecurityConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException ()
18
- {
19
- $ this ->expectException (SecurityIsNotDefinedException::class);
20
-
21
- $ this ->configLoader ->load ('SecurityConfiguration.php ' );
22
- $ this ->container ->compile ();
23
-
24
- $ this ->container ->get ('openclassrooms.tests.use_cases.configuration_security_use_case_stub ' );
25
- }
26
-
27
- /**
28
- * @test
29
- */
30
- public function WithDefaultConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException ()
31
- {
32
- $ this ->expectException (SecurityIsNotDefinedException::class);
33
-
34
- $ this ->configLoader ->load ('DefaultConfiguration.php ' );
35
- $ this ->container ->compile ();
36
-
37
- $ this ->container ->get ('openclassrooms.tests.use_cases.configuration_security_use_case_stub ' );
38
- }
39
-
40
14
/**
41
15
* @test
42
16
*/
You can’t perform that action at this time.
0 commit comments