Skip to content

Commit 64b5c85

Browse files
committed
ISSUE-345: tests folder restructure
1 parent 9377cb5 commit 64b5c85

File tree

55 files changed

+501
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+501
-95
lines changed

config/services/validators.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
autoconfigure: true
55
public: false
66

7-
PhpList\RestBundle\Identity\Validator\UniqueEmailValidator:
7+
PhpList\RestBundle\Identity\Validator\Constraint\UniqueEmailValidator:
88
autowire: true
99
autoconfigure: true
1010
tags: [ 'validator.constraint_validator' ]
@@ -24,14 +24,6 @@ services:
2424
autoconfigure: true
2525
tags: [ 'validator.constraint_validator' ]
2626

27-
PhpList\Core\Domain\Service\Validator\TemplateLinkValidator:
28-
autowire: true
29-
autoconfigure: true
30-
31-
PhpList\Core\Domain\Service\Validator\TemplateImageValidator:
32-
autowire: true
33-
autoconfigure: true
34-
3527
PhpList\RestBundle\Messaging\Validator\Constraint\ContainsPlaceholderValidator:
3628
tags: ['validator.constraint_validator']
3729

src/Common/Validator/RequestValidator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function validate(Request $request, string $dtoClass): RequestInterface
3838
if (isset($routeParams['listId'])) {
3939
$routeParams['listId'] = (int) $routeParams['listId'];
4040
}
41+
if (isset($routeParams['administratorId'])) {
42+
$routeParams['administratorId'] = (int) $routeParams['administratorId'];
43+
}
4144

4245
$data = array_merge($routeParams, $body ?? []);
4346

src/Identity/Controller/AdministratorController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function updateAdministrator(
230230
$updateRequest = $this->validator->validate($request, UpdateAdministratorRequest::class);
231231
$this->administratorManager->updateAdministrator($administrator, $updateRequest->getDto());
232232

233-
return $this->json(null, Response::HTTP_OK);
233+
return $this->json($this->normalizer->normalize($administrator), Response::HTTP_OK);
234234
}
235235

236236
#[Route('/{administratorId}', name: 'delete_administrator', methods: ['DELETE'])]

src/Identity/Validator/Constraint/UniqueEmailValidator.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PhpList\RestBundle\Identity\Validator\Constraint;
66

7-
use Doctrine\ORM\EntityManagerInterface;
7+
use PhpList\Core\Domain\Identity\Repository\AdministratorRepository;
88
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
99
use Symfony\Component\Validator\Constraint;
1010
use Symfony\Component\Validator\ConstraintValidator;
@@ -13,7 +13,7 @@
1313

1414
class UniqueEmailValidator extends ConstraintValidator
1515
{
16-
public function __construct(private readonly EntityManagerInterface $entityManager)
16+
public function __construct(private readonly AdministratorRepository $repository)
1717
{
1818
}
1919

@@ -31,9 +31,7 @@ public function validate($value, Constraint $constraint): void
3131
throw new UnexpectedValueException($value, 'string');
3232
}
3333

34-
$existingUser = $this->entityManager
35-
->getRepository($constraint->entityClass)
36-
->findOneBy(['email' => $value]);
34+
$existingUser = $this->repository->findOneBy(['email' => $value]);
3735

3836
$dto = $this->context->getObject();
3937
$updatingId = $dto->administratorId ?? null;

src/Subscription/Controller/SubscriberAttributeDefinitionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\HttpFoundation\Response;
2121
use Symfony\Component\Routing\Attribute\Route;
2222

23-
#[Route('/subscriber/attributes')]
23+
#[Route('/subscribers/attributes')]
2424
class SubscriberAttributeDefinitionController extends BaseController
2525
{
2626
private AttributeDefinitionManager $definitionManager;

src/Subscription/Controller/SubscriberAttributeController.php renamed to src/Subscription/Controller/SubscriberAttributeValueController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
use Symfony\Component\HttpFoundation\Response;
2222
use Symfony\Component\Routing\Attribute\Route;
2323

24-
#[Route('/subscriber/attribute-values')]
25-
class SubscriberAttributeController extends BaseController
24+
#[Route('/subscribers/attribute-values')]
25+
class SubscriberAttributeValueController extends BaseController
2626
{
2727
private SubscriberAttributeManager $attributeManager;
2828
private SubscriberAttributeValueNormalizer $normalizer;
@@ -114,7 +114,7 @@ public function createOrUpdate(
114114
$attributeDefinition = $this->attributeManager->createOrUpdate(
115115
subscriber:$subscriber,
116116
definition: $definition,
117-
value: $request->get('value')
117+
value: $request->toArray()['value'] ?? null
118118
);
119119
$json = $this->normalizer->normalize($attributeDefinition, 'json');
120120

tests/Integration/Controller/AbstractTestController.php renamed to tests/Integration/Common/AbstractTestController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
declare(strict_types=1);
44

5-
namespace PhpList\RestBundle\Tests\Integration\Controller;
5+
namespace PhpList\RestBundle\Tests\Integration\Common;
66

77
use Doctrine\ORM\Tools\SchemaTool;
88
use PhpList\Core\TestingSupport\Traits\DatabaseTestTrait;
9-
use PhpList\RestBundle\Tests\Integration\Controller\Fixtures\Identity\AdministratorFixture;
10-
use PhpList\RestBundle\Tests\Integration\Controller\Fixtures\Identity\AdministratorTokenFixture;
9+
use PhpList\RestBundle\Tests\Integration\Identity\Fixtures\AdministratorFixture;
10+
use PhpList\RestBundle\Tests\Integration\Identity\Fixtures\AdministratorTokenFixture;
1111
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1212
use Symfony\Component\DomCrawler\Crawler;
1313
use Symfony\Component\HttpFoundation\Response;

tests/Integration/EventListener/ExceptionListenerTest.php renamed to tests/Integration/Common/EventListener/ExceptionListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace PhpList\RestBundle\Tests\Integration\EventListener;
5+
namespace PhpList\RestBundle\Tests\Integration\Common\EventListener;
66

77
use PhpList\Core\Domain\Subscription\Exception\SubscriptionCreationException;
88
use PhpList\RestBundle\Common\EventListener\ExceptionListener;

tests/Integration/EventListener/ResponseListenerTest.php renamed to tests/Integration/Common/EventListener/ResponseListenerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
namespace PhpList\RestBundle\Tests\Integration\EventListener;
3+
declare(strict_types=1);
4+
5+
namespace PhpList\RestBundle\Tests\Integration\Common\EventListener;
46

57
use PhpList\RestBundle\Common\EventListener\ResponseListener;
68
use PHPUnit\Framework\TestCase;

tests/Integration/Routing/RoutingTest.php renamed to tests/Integration/Common/Routing/RoutingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace PhpList\RestBundle\Tests\Integration\Routing;
5+
namespace PhpList\RestBundle\Tests\Integration\Common\Routing;
66

77
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
88

0 commit comments

Comments
 (0)