-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout de la page detail de l'autorité signataire (#1067)
- Loading branch information
Showing
8 changed files
with
182 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ture/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Infrastructure\Controller\MyArea\Organization\SigningAuthority; | ||
|
||
use App\Application\Organization\SigningAuthority\Query\GetSigningAuthorityByOrganizationQuery; | ||
use App\Application\QueryBusInterface; | ||
use App\Infrastructure\Controller\MyArea\Organization\AbstractOrganizationController; | ||
use Symfony\Bundle\SecurityBundle\Security; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Routing\Requirement\Requirement; | ||
|
||
final class SigningAuthorityDetailController extends AbstractOrganizationController | ||
{ | ||
public function __construct( | ||
private \Twig\Environment $twig, | ||
QueryBusInterface $queryBus, | ||
Security $security, | ||
) { | ||
parent::__construct($queryBus, $security); | ||
} | ||
|
||
#[Route( | ||
'/organizations/{uuid}/signing_authority', | ||
name: 'app_config_signing_authority_detail', | ||
requirements: ['uuid' => Requirement::UUID], | ||
methods: ['GET'], | ||
)] | ||
public function __invoke(string $uuid): Response | ||
{ | ||
$signingAuthority = $this->queryBus->handle(new GetSigningAuthorityByOrganizationQuery($uuid)); | ||
$organization = $this->getOrganization($uuid); | ||
|
||
return new Response( | ||
content: $this->twig->render( | ||
name: 'my_area/organization/signing_authority/detail.html.twig', | ||
context: [ | ||
'signingAuthority' => $signingAuthority, | ||
'organization' => $organization, | ||
], | ||
), | ||
); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Infrastructure/Persistence/Doctrine/Fixtures/SigningAuthorityFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Infrastructure\Persistence\Doctrine\Fixtures; | ||
|
||
use App\Domain\Organization\SigningAuthority\SigningAuthority; | ||
use Doctrine\Bundle\FixturesBundle\Fixture; | ||
use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||
use Doctrine\Persistence\ObjectManager; | ||
|
||
final class SigningAuthorityFixture extends Fixture implements DependentFixtureInterface | ||
{ | ||
public function load(ObjectManager $manager): void | ||
{ | ||
$signatoryAuthority = new SigningAuthority( | ||
uuid: '9cebe00d-04d8-48da-89b1-059f6b7bfe44', | ||
name: 'Monsieur le maire de Savenay', | ||
address: '3 rue de la Concertation', | ||
placeOfSignature: 'Savenay', | ||
signatoryName: 'Monsieur X, Maire de Savenay', | ||
organization: $this->getReference('mainOrg'), | ||
); | ||
|
||
$manager->persist($signatoryAuthority); | ||
$manager->flush(); | ||
} | ||
|
||
public function getDependencies(): array | ||
{ | ||
return [ | ||
OrganizationFixture::class, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
templates/my_area/organization/signing_authority/detail.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends 'layouts/layout.html.twig' %} | ||
{% set metaTitle = 'signing_authority.form.title'|trans %} | ||
{% block title %} | ||
{{ metaTitle }} - {{ parent() }} | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<section class="fr-container fr-py-5w"> | ||
<div class="fr-grid-row fr-grid-row--gutters"> | ||
<div class="fr-col-12 fr-col-md-4"> | ||
{% include 'my_area/organization/_menu.html.twig' with { organization } only %} | ||
</div> | ||
<div class="fr-col-12 fr-col-md-8"> | ||
{% include "common/breadcrumb.html.twig" with { items: [ | ||
{ title: 'user.myarea'|trans, path: 'app_my_area'}, | ||
{ title: metaTitle }, | ||
]} %} | ||
<div class="fr-grid-row fr-x-gap-2w" data-testid="signing_authority"> | ||
<div class="fr-x-grow-32w"> | ||
<h2 class="fr-mb-0">{{ metaTitle }}</h2> | ||
<p class="fr-my-2w fr-text--sm fr-message--info"> | ||
{{ 'signing_authority.help'|trans }} | ||
</p> | ||
<ul> | ||
<li><b>{{ 'signing_authority.name'|trans }}</b> : {{ signingAuthority.name|default('N/D') }}</li> | ||
<li><b>{{ 'signing_authority.address'|trans }}</b> : {{ signingAuthority.address|default('N/D') }}</li> | ||
<li><b>{{ 'signing_authority.placeOfSignature'|trans }}</b> : {{ signingAuthority.placeOfSignature|default('N/D') }}</li> | ||
<li><b>{{ 'signing_authority.signatoryName'|trans }}</b> : {{ signingAuthority.signatoryName|default('N/D') }}</li> | ||
</ul> | ||
</div> | ||
<div class="fr-mb-3w"> | ||
{% if is_granted(constant('App\\Infrastructure\\Security\\Voter\\OrganizationVoter::EDIT'), organization) %} | ||
<a href="{{ path('app_config_signing_authority_edit', { uuid: organization.uuid }) }}" class="fr-ml-auto fr-btn fr-btn--secondary fr-x-btn-sm--icon-left fr-icon-edit-line" title="{{ 'common.update'|trans }}"> | ||
{{ 'common.update'|trans }} | ||
</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
.../Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Integration\Infrastructure\Controller\MyArea\Organization\SigningAuthority; | ||
|
||
use App\Infrastructure\Persistence\Doctrine\Fixtures\OrganizationFixture; | ||
use App\Tests\Integration\Infrastructure\Controller\AbstractWebTestCase; | ||
|
||
final class SigningAuthorityDetailControllerTest extends AbstractWebTestCase | ||
{ | ||
public function testDetail(): void | ||
{ | ||
$client = $this->login('[email protected]'); | ||
$crawler = $client->request('GET', '/mon-espace/organizations/' . OrganizationFixture::MAIN_ORG_ID . '/signing_authority'); | ||
|
||
$this->assertResponseStatusCodeSame(200); | ||
$this->assertSecurityHeaders(); | ||
$this->assertSame('Autorité signataire', $crawler->filter('h2')->text()); | ||
$this->assertMetaTitle('Autorité signataire - DiaLog', $crawler); | ||
|
||
$this->assertSame($crawler->filter('[data-testid="signing_authority"] ul')->text(), 'Intitulé du signataire : Monsieur le maire de Savenay Adresse de l\'établissement : 3 rue de la Concertation Fait à : Savenay Nom du signataire : Monsieur X, Maire de Savenay'); | ||
} | ||
|
||
public function testNotAdministrator(): void | ||
{ | ||
$client = $this->login(); | ||
$client->request('GET', '/mon-espace/organizations/' . OrganizationFixture::MAIN_ORG_ID . '/signing_authority'); | ||
$this->assertResponseStatusCodeSame(200); | ||
} | ||
|
||
public function testOrganizationNotOwned(): void | ||
{ | ||
$client = $this->login(); | ||
$client->request('GET', '/mon-espace/organizations/' . OrganizationFixture::OTHER_ORG_ID . '/signing_authority'); | ||
$this->assertResponseStatusCodeSame(403); | ||
} | ||
|
||
public function testOrganizationOrUserNotFound(): void | ||
{ | ||
$client = $this->login(); | ||
$client->request('GET', '/mon-espace/organizations/f5c1cea8-a61d-43a7-9b5d-4b8c9557c673/signing_authority'); | ||
$this->assertResponseStatusCodeSame(404); | ||
} | ||
|
||
public function testWithoutAuthenticatedUser(): void | ||
{ | ||
$client = static::createClient(); | ||
$client->request('GET', '/mon-espace/organizations/' . OrganizationFixture::MAIN_ORG_ID . '/signing_authority'); | ||
$this->assertResponseRedirects('http://localhost/login', 302); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters