Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Jan 30, 2025
1 parent 02ddfe5 commit a2fbb71
Show file tree
Hide file tree
Showing 20 changed files with 138 additions and 299 deletions.
1 change: 0 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
'@PHP82Migration' => true,
'@PHP80Migration:risky' => true,
'@Symfony' => true,
'@DoctrineAnnotation' => true,
'phpdoc_summary' => false,
'no_unneeded_final_method' => false,
'declare_strict_types' => false,
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"league/iso3166": "^4.3",
"league/oauth2-server": "^8.2",
"lexik/paybox-bundle": "dev-master",
"longitude-one/doctrine-spatial": "*",
"longitude-one/doctrine-spatial": "^4.0",
"myclabs/php-enum": "^1.5",
"nelmio/cors-bundle": "^2.2",
"nyholm/psr7": "^1.5",
Expand All @@ -81,11 +81,10 @@
"phpoffice/phpspreadsheet": "^3.3",
"ramsey/uuid": "^4.1",
"ramsey/uuid-doctrine": "^2.0",
"runroom-packages/sortable-behavior-bundle": "^0.17.1",
"runroom-packages/sortable-behavior-bundle": "^0.18.0",
"sabre/dav": "^4.1",
"scheb/2fa-bundle": "^6.3",
"scheb/2fa-google-authenticator": "^6.3",
"sensio/framework-extra-bundle": "^6.0",
"sentry/sentry-symfony": "^5.0",
"sonata-project/admin-bundle": "^4.32",
"sonata-project/doctrine-orm-admin-bundle": "^4.15",
Expand Down
306 changes: 83 additions & 223 deletions composer.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/Controller/Admin/AdminCommitteeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use App\Repository\CommitteeRepository;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Cache\CacheItemPoolInterface;
use DoctrineExtensions\Query\Mysql\Exp;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Request;
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/Api/AppLink/AuthenticatedAppLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace App\Controller\Api\AppLink;

use App\Controller\Renaissance\Adhesion\AdhesionController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use App\Entity\Adherent;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Api/Filter/GetCollectionFiltersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
use App\JMEFilter\FiltersGenerator;
use App\Scope\ScopeGeneratorResolver;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[IsGranted(new Expression("is_granted('REQUEST_SCOPE_GRANTED', ['contacts', 'messages'])"))]
#[Route(path: '/v3/filters', name: 'app_collection_filters_get', methods: ['GET'])]
#[Security("is_granted('REQUEST_SCOPE_GRANTED', ['contacts', 'messages'])")]
class GetCollectionFiltersController extends AbstractController
{
public function __construct(
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Api/Security/GetJWTTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
use App\OAuth\JWTTokenGenerator;
use App\Security\Voter\OAuthClientVoter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[IsGranted(new Expression("is_granted('REQUEST_SCOPE_GRANTED', 'featurebase')"))]
#[Route(path: '/v3/sso/jwt/{uuid}', name: 'api_security_get_jwt_token', methods: ['GET'])]
#[Security("is_granted('REQUEST_SCOPE_GRANTED', 'featurebase')")]
class GetJWTTokenController extends AbstractController
{
public function __invoke(Client $client, JWTTokenGenerator $tokenGenerator): Response
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
Expand Down
3 changes: 0 additions & 3 deletions src/Controller/EnMarche/CommitteeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
use App\Mailchimp\Synchronisation\Command\AdherentChangeCommand;
use App\Security\Http\Session\AnonymousFollowerSession;
use App\Security\Voter\Committee\ChangeCommitteeVoter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down
33 changes: 0 additions & 33 deletions src/Controller/EnMarche/LegacyController.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[IsGranted(new Expression('is_granted("ABLE_TO_CHANGE_COMMITTEE") or is_granted("IS_IMPERSONATOR")'))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[IsGranted(new Expression('is_granted("ABLE_TO_CHANGE_COMMITTEE") or is_granted("IS_IMPERSONATOR")'))]
Expand Down
9 changes: 8 additions & 1 deletion src/Entity/EntityIdentityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Metadata\ApiProperty;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Serializer\Attribute\Groups;
Expand Down Expand Up @@ -35,12 +35,19 @@ trait EntityIdentityTrait
'adherent_message_update_filter',
'audience_list_read',
'audience_read',
'committee_candidacies_group:write',
'elected_representative_write',
'elected_mandate_write',
'audience_segment_read',
'my_team_member_write',
'cause_read',
'committee:list',
'committee:update_animator',
'committee:read',
'committee_candidacies_group:read',
'committee_candidacy:read',
'jecoute_news_write',
'pap_campaign_history_write',
'committee_election:read',
'contact_read',
'contact_read_after_write',
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Event/BaseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ abstract class BaseEvent implements ReportableInterface, GeoPointInterface, Addr
/**
* @var EventCategoryInterface|EventCategory|null
*/
#[Groups(['event_read', 'event_list_read', 'event_write'])]
#[Groups(['event_read', 'event_list_read', 'event_write', 'event_write_creation'])]
#[ORM\ManyToOne(targetEntity: EventCategory::class)]
protected $category;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Event/BaseEventCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Entity\Event;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Metadata\ApiProperty;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Attribute\Groups;
Expand Down Expand Up @@ -33,7 +33,7 @@ abstract class BaseEventCategory implements EventCategoryInterface
#[Assert\Length(max: 100)]
#[Assert\NotBlank]
#[Gedmo\Slug(fields: ['name'], unique: true)]
#[Groups(['event_read', 'event_list_read', 'event_category_read'])]
#[Groups(['event_read', 'event_list_read', 'event_category_read', 'event_write'])]
#[ORM\Column(length: 100, unique: true)]
protected $slug;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Event/EventCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#[ApiResource(
operations: [
new Get(),
new GetCollection(uriTemplate: '/event_categories'),
new GetCollection(),
],
normalizationContext: ['groups' => ['event_category_read']],
order: ['slug' => 'ASC'],
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Geo/GeoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Entity\Geo;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Metadata\ApiProperty;
use App\Entity\GeoData;
use App\Entity\GeoPointTrait;
use Doctrine\ORM\Mapping as ORM;
Expand Down
36 changes: 36 additions & 0 deletions src/Normalizer/EntityCategoryFromSlugDenormalizer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Normalizer;

use ApiPlatform\Exception\ItemNotFoundException;
use App\Entity\Event\EventCategory;
use App\Repository\EventCategoryRepository;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;

class EntityCategoryFromSlugDenormalizer implements DenormalizerInterface
{
public function __construct(private readonly EventCategoryRepository $repository)
{
}

public function denormalize($data, $type, $format = null, array $context = []): mixed
{
if ($object = $this->repository->findOneBy(['slug' => $data])) {
return $object;
}

throw new ItemNotFoundException(\sprintf('Category "%s" with slug "%s" not found', $type, $data));
}

public function getSupportedTypes(?string $format): array
{
return [
'*' => true,
];
}

public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return \is_string($data) && EventCategory::class === $type;
}
}
21 changes: 0 additions & 21 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@
"ref": "56eaa387b5e48ebcc7c95a893b47dfa1ad51449c"
}
},
"doctrine/annotations": {
"version": "2.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.10",
"ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05"
}
},
"doctrine/doctrine-bundle": {
"version": "2.5",
"recipe": {
Expand Down Expand Up @@ -253,18 +244,6 @@
"config/routes/scheb_2fa.yaml"
]
},
"sensio/framework-extra-bundle": {
"version": "6.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.2",
"ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b"
},
"files": [
"config/packages/sensio_framework_extra.yaml"
]
},
"sentry/sentry-symfony": {
"version": "4.3",
"recipe": {
Expand Down
1 change: 0 additions & 1 deletion tests/Controller/Admin/SecurityControllerCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function testAuthenticationIfSecretCode(): void
$this->assertClientIsRedirectedTo('/login/2fa', $this->client, true);

$crawler = $this->client->followRedirect();
$content = $this->client->getResponse()->getContent();

$this->assertResponseStatusCode(Response::HTTP_OK, $this->client->getResponse());
$this->assertCount(1, $crawler->filter('#_auth_code'));
Expand Down

0 comments on commit a2fbb71

Please sign in to comment.