Minor fixes
This commit is contained in:
parent
f3d5d729bf
commit
c524592485
7 changed files with 10 additions and 86 deletions
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Controller\Api;
|
||||
|
||||
use App\Entity\Rating;
|
||||
use App\Entity\Restaurant;
|
||||
use App\Repository\RatingRepository;
|
||||
use App\Repository\SubjectRepository;
|
||||
use App\Services\OutputService;
|
||||
|
|
@ -42,7 +41,7 @@ class RatingController extends AbstractController
|
|||
OutputService $output,
|
||||
SubjectRepository $subjectRepository,
|
||||
): JsonResponse {
|
||||
$subject = $subjectRepository->findById($request->getPayload()->get('subject_id'));
|
||||
$subject = $subjectRepository->find($request->getPayload()->get('subject_id'));
|
||||
|
||||
if ($subject === null) {
|
||||
return $this->json(
|
||||
|
|
@ -68,7 +67,7 @@ class RatingController extends AbstractController
|
|||
OutputService $output,
|
||||
RatingRepository $ratingRepository,
|
||||
): JsonResponse {
|
||||
$rating = $ratingRepository->findById($id);
|
||||
$rating = $ratingRepository->find($id);
|
||||
|
||||
if ($rating === null) {
|
||||
return $this->json(
|
||||
|
|
@ -98,7 +97,7 @@ class RatingController extends AbstractController
|
|||
OutputService $output,
|
||||
RatingRepository $ratingRepository,
|
||||
): JsonResponse {
|
||||
$rating = $ratingRepository->findById($id);
|
||||
$rating = $ratingRepository->find($id);
|
||||
|
||||
if ($rating === null) {
|
||||
return $this->json(
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ class SubjectController extends AbstractController
|
|||
OutputService $output,
|
||||
SubjectRepository $repository,
|
||||
): JsonResponse {
|
||||
$subject = $repository->findById($id);
|
||||
$subject = $repository->find($id);
|
||||
|
||||
if ($subject === null) {
|
||||
return $this->json(
|
||||
$output->error(["UNKNOWN_RATING"])
|
||||
$output->error(["UNKNOWN_SUBJECT"])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -74,10 +74,10 @@ class SubjectController extends AbstractController
|
|||
OutputService $output,
|
||||
SubjectRepository $repository,
|
||||
): JsonResponse {
|
||||
$subject = $repository->findById($id);
|
||||
$subject = $repository->find($id);
|
||||
|
||||
if ($subject === null) {
|
||||
return $this->json($output->error(["UNKNOWN_RATING"]));
|
||||
return $this->json($output->error(["UNKNOWN_SUBJECT"]));
|
||||
}
|
||||
|
||||
$em->remove($subject);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Rating
|
|||
return $this->note;
|
||||
}
|
||||
|
||||
public function setNote(?string $note = ''): static
|
||||
public function setNote(string $note): static
|
||||
{
|
||||
$this->note = $note;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,15 +17,6 @@ class RatingRepository extends ServiceEntityRepository
|
|||
parent::__construct($registry, Rating::class);
|
||||
}
|
||||
|
||||
public function findById(int $id): ?Rating
|
||||
{
|
||||
return $this->createQueryBuilder('r')
|
||||
->where('r.id = :id')
|
||||
->setParameter('id', $id)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Rating[]
|
||||
*/
|
||||
|
|
@ -37,29 +28,4 @@ class RatingRepository extends ServiceEntityRepository
|
|||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Rating[] Returns an array of Rating objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('r.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Rating
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,38 +15,4 @@ class SubjectRepository extends ServiceEntityRepository
|
|||
{
|
||||
parent::__construct($registry, Subject::class);
|
||||
}
|
||||
|
||||
public function findById(int $id): ?Subject
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->where('s.id = :id')
|
||||
->setParameter('id', $id)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Subject[] Returns an array of Subject objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('s.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Subject
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests\Unit\Controller\Api;
|
||||
namespace App\Tests\Application\Controller\Api;
|
||||
|
||||
use App\Entity\Rating;
|
||||
use App\Entity\Restaurant;
|
||||
use App\Factory\RatingFactory;
|
||||
use App\Factory\RestaurantFactory;
|
||||
use App\Factory\UserFactory;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests\Unit\Controller\Api;
|
||||
namespace App\Tests\Application\Controller\Api;
|
||||
|
||||
use App\Entity\Rating;
|
||||
use App\Entity\Restaurant;
|
||||
use App\Entity\Subject;
|
||||
use App\Factory\RatingFactory;
|
||||
use App\Factory\RestaurantFactory;
|
||||
use App\Factory\SubjectFactory;
|
||||
use App\Factory\UserFactory;
|
||||
|
|
@ -26,10 +24,6 @@ class SubjectControllerTest extends WebTestCase
|
|||
'createdBy' => $user,
|
||||
]);
|
||||
|
||||
static::getContainer()
|
||||
->get(SubjectRepository::class)
|
||||
->findOneBy(['name' => 'Riviera']);
|
||||
|
||||
$client->request(
|
||||
'GET',
|
||||
'/api/subjects',
|
||||
|
|
|
|||
Loading…
Reference in a new issue