Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .coveralls.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<call method="setReader">
<argument type="service" id="annotation_reader"/>
</call>
<argument type="service" id="security.authorization_checker"/>
</service>
<service id="openclassrooms.use_case.security_factory" class="OpenClassrooms\Bundle\UseCaseBundle\Services\Security\Impl\SecurityFactoryImpl" public="true"/>
<service id="openclassrooms.use_case.transaction_factory" class="OpenClassrooms\Bundle\UseCaseBundle\Services\Transaction\Impl\TransactionFactoryImpl" public="true"/>
Expand Down
14 changes: 4 additions & 10 deletions Services/Proxy/Impl/UseCaseProxyFactoryImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class UseCaseProxyFactoryImpl implements UseCaseProxyFactory
*/
private $builder;

public function __construct()
public function __construct(
private readonly AuthorizationCheckerInterface $authorizationChecker
)
{
$this->builder = new UseCaseProxyBuilderImpl();
}
Expand Down Expand Up @@ -114,15 +116,7 @@ private function buildSecurity(array $tagParameters)
if (isset($tagParameters['security'])) {
$security = $this->container->get($tagParameters['security']);
} else {
$defaultSecurityContextId = $this->container->getParameter(
'openclassrooms.use_case.default_authorization_checker'
);
if (!$this->container->has($defaultSecurityContextId)) {
throw new SecurityIsNotDefinedException('Default security context: \''.$defaultSecurityContextId.'\' is not defined.');
}
$security = $this->container->get(
$this->container->getParameter('openclassrooms.use_case.default_authorization_checker')
);
$security = $this->authorizationChecker;
}
if ($security instanceof AuthorizationCheckerInterface) {
/** @var SecurityFactory $securityFactory */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<parameter key="openclassrooms.tests.use_cases.event_use_case_stub.class">OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\EventUseCaseStub</parameter>
</parameters>
<services>
<service id="security.authorization_checker" class="OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util\AuthorizationCheckerSpy"/>
<service id="annotation_reader" class="Doctrine\Common\Annotations\AnnotationReader"/>
<service id="openclassrooms.tests.util.security_stub" class="%openclassrooms.tests.util.security_stub.class%" public="true"/>
<service id="openclassrooms.tests.util.authorization_checker_stub" class="%openclassrooms.tests.util.authorization_checker_stub.class%" public="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,6 @@
*/
class SecurityOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTestCase
{
/**
* @test
*/
public function WithSecurityConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException()
{
$this->expectException(SecurityIsNotDefinedException::class);

$this->configLoader->load('SecurityConfiguration.php');
$this->container->compile();

$this->container->get('openclassrooms.tests.use_cases.configuration_security_use_case_stub');
}

/**
* @test
*/
public function WithDefaultConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException()
{
$this->expectException(SecurityIsNotDefinedException::class);

$this->configLoader->load('DefaultConfiguration.php');
$this->container->compile();

$this->container->get('openclassrooms.tests.use_cases.configuration_security_use_case_stub');
}

/**
* @test
*/
Expand Down
Loading