From f02873c6e07282801fad86674699d76cf47c636e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 8 Dec 2023 11:07:14 +0100 Subject: [PATCH 1/2] Refactor RelationshipApiControllerTest The codebase has been improved by refining and optimizing the test methods in the RelationshipApiControllerTest class. The check for relations was also added to exclude persons without any relationship, this may exclude duplicate relations. This change should avoid errors on this test. --- .../RelationshipApiControllerTest.php | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php index 7e191b91e..171dedacb 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Controller; use Chill\MainBundle\Test\PrepareClientTrait; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Relationships\Relation; +use Chill\PersonBundle\Entity\Relationships\Relationship; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; @@ -43,31 +44,34 @@ final class RelationshipApiControllerTest extends WebTestCase { self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); - $countPersons = $em->createQueryBuilder() - ->select('count(p)') - ->from(Person::class, 'p') - ->join('p.centerCurrent', 'center_current') - ->join('center_current.center', 'c') - ->where('c.name LIKE :name') - ->setParameter('name', 'Center A') - ->getQuery() - ->getSingleScalarResult(); - $person = $em->createQueryBuilder() - ->select('p') + $personIdHavingRelation = $em->createQueryBuilder() + ->select('p.id') ->from(Person::class, 'p') ->join('p.centerCurrent', 'center_current') ->join('center_current.center', 'c') ->where('c.name LIKE :name') + ->andWhere('EXISTS (SELECT 1 FROM ' . Relationship::class . ' r WHERE r.fromPerson = p OR r.toPerson = p)') ->setParameter('name', 'Center A') ->getQuery() ->setMaxResults(1) - ->setFirstResult(\random_int(0, $countPersons - 1)) - ->getSingleResult(); + ->getSingleScalarResult(); + + $personIdWithoutRelation = $em->createQueryBuilder() + ->select('p.id') + ->from(Person::class, 'p') + ->join('p.centerCurrent', 'center_current') + ->join('center_current.center', 'c') + ->where('c.name LIKE :name') + ->andWhere('NOT EXISTS (SELECT 1 FROM ' . Relationship::class . ' r WHERE r.fromPerson = p OR r.toPerson = p)') + ->setParameter('name', 'Center A') + ->getQuery() + ->setMaxResults(1) + ->getSingleScalarResult(); self::ensureKernelShutdown(); return [ - [$person->getId()], + [$personIdHavingRelation, $personIdWithoutRelation], ]; } @@ -75,39 +79,29 @@ final class RelationshipApiControllerTest extends WebTestCase { self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); - $countPersons = $em->createQueryBuilder() - ->select('count(DISTINCT p)') - ->from(Person::class, 'p') - ->join('p.centerCurrent', 'center_current') - ->join('center_current.center', 'c') - ->where('c.name LIKE :name') - ->setParameter('name', 'Center A') - ->getQuery() - ->getSingleScalarResult(); - - $persons = $em->createQueryBuilder() - ->select('p') + $personIdWithoutRelations = $em->createQueryBuilder() + ->select('p.id') ->from(Person::class, 'p') ->join('p.centerCurrent', 'center_current') ->join('center_current.center', 'c') ->where('c.name LIKE :name') + ->andWhere('NOT EXISTS (SELECT 1 FROM ' . Relationship::class . ' r WHERE r.fromPerson = p OR r.toPerson = p)') ->setParameter('name', 'Center A') ->getQuery() ->setMaxResults(2) - ->setFirstResult(\random_int(0, $countPersons - 1)) ->getResult(); self::ensureKernelShutdown(); return [ - [$persons[0]->getId(), $persons[1]->getId(), $this->getRandomRelation($em)->getId(), true], + [$personIdWithoutRelations[0]['id'], $personIdWithoutRelations[1]['id'], $this->getRandomRelation($em)->getId(), true], ]; } /** * @dataProvider personProvider */ - public function testGetRelationshipByPerson(mixed $personId) + public function testGetRelationshipByPerson(int $personId) { self::ensureKernelShutdown(); $client = $this->getClientAuthenticated(); From 0ad27328c9cdd1b912baa1918ac04a97d863e861 Mon Sep 17 00:00:00 2001 From: juminet Date: Wed, 13 Dec 2023 08:39:56 +0000 Subject: [PATCH 2/2] DX: re-instate the build of documentation on read-the-docs --- .changes/unreleased/DX-20231212-154458.yaml | 6 ++++++ .readthedocs.yml | 8 ++++++-- docs/README.md | 2 +- docs/requirements.txt | 1 + docs/source/installation/index.rst | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/DX-20231212-154458.yaml diff --git a/.changes/unreleased/DX-20231212-154458.yaml b/.changes/unreleased/DX-20231212-154458.yaml new file mode 100644 index 000000000..ae534a693 --- /dev/null +++ b/.changes/unreleased/DX-20231212-154458.yaml @@ -0,0 +1,6 @@ +kind: DX +body: Fixed readthedocs compilation by updating readthedocs config file and requirements + for Sphinx +time: 2023-12-12T15:44:58.282590276+01:00 +custom: + Issue: "167" diff --git a/.readthedocs.yml b/.readthedocs.yml index 3b5a7def9..cd8f36eba 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,10 +1,14 @@ --- version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.7" + sphinx: configuration: docs/source/conf.py python: - version: 3.7 install: - - requirements: docs/requirements.txt + - requirements: docs/requirements.txt \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 98b199f02..8ae7f650a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -27,7 +27,7 @@ To compile this documentation : Contribute =========== -Issue tracker : https://git.framasoft.org/groups/Chill-project/issues +Issue tracker : https://gitlab.com/Chill-Projet/chill-bundles/-/issues Licence ======= diff --git a/docs/requirements.txt b/docs/requirements.txt index 26a019bfa..a8d979a2b 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,6 +1,7 @@ docutils==0.13.1 Pygments==2.2.0 sphinx==1.8.5 +Jinja2<3.1 git+https://github.com/fabpot/sphinx-php.git@v2.0.2#egg_name=sphinx-php jsx-lexer===0.0.8 sphinx_rtd_theme==0.5.0 diff --git a/docs/source/installation/index.rst b/docs/source/installation/index.rst index 910122196..9e6f2ed87 100644 --- a/docs/source/installation/index.rst +++ b/docs/source/installation/index.rst @@ -49,7 +49,7 @@ Clone or download the chill-skeleton project and `cd` into the main directory. .. code-block:: bash git clone https://gitlab.com/Chill-Projet/chill-skeleton-basic.git - cd chill-app + cd chill-skeleton-basic As a developer, the code will stay on your computer and will be executed in docker container. To avoid permission problem, the code should be run with the same uid/gid from your current user. This is why we get your current user id with the command ``id -u`` in each following scripts.