From 06d698c44421e1f3ddaa04b0d6f6a2230de2ee03 Mon Sep 17 00:00:00 2001 From: Camille Simiand <camille.simiand@tetras-libre.fr> Date: Tue, 11 Jan 2022 10:24:00 +0100 Subject: [PATCH] Rebase and fix errors --- src/Entity/User.php | 43 +--------------------- tests/functional/ProjectControllerTest.php | 18 ++++----- 2 files changed, 9 insertions(+), 52 deletions(-) diff --git a/src/Entity/User.php b/src/Entity/User.php index 8e66be0..6f204e6 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -3,8 +3,6 @@ namespace App\Entity; use App\Repository\UserRepository; -use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface; @@ -84,17 +82,8 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface */ private string $salt; - /** - * @ORM\OneToMany(targetEntity=Capsule::class, mappedBy="aut_crea") - */ - private $capsules; - - public function __construct() - { - $this->capsules = new ArrayCollection(); - } - public function getId(): ?int + public function getId(): int { return $this->id; } @@ -224,34 +213,4 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface { $this->salt = $salt; } - - /** - * @return Collection|Capsule[] - */ - public function getCapsules(): Collection - { - return $this->capsules; - } - - public function addCapsule(Capsule $capsule): self - { - if (!$this->capsules->contains($capsule)) { - $this->capsules[] = $capsule; - $capsule->setCreationauthor($this); - } - - return $this; - } - - public function removeCapsule(Capsule $capsule): self - { - if ($this->capsules->removeElement($capsule)) { - // set the owning side to null (unless already changed) - if ($capsule->getCreationauthor() === $this) { - $capsule->setCreationauthor(null); - } - } - - return $this; - } } diff --git a/tests/functional/ProjectControllerTest.php b/tests/functional/ProjectControllerTest.php index 4803c99..0935ff7 100644 --- a/tests/functional/ProjectControllerTest.php +++ b/tests/functional/ProjectControllerTest.php @@ -9,7 +9,6 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\DomCrawler\Form; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Config\TwigExtra\StringConfig; class ProjectControllerTest extends WebTestCase { @@ -18,8 +17,6 @@ class ProjectControllerTest extends WebTestCase private Form $form; private const TEST_DIR_PATH = __DIR__ . '/../../legacy/'; private const CAPSULE_NAME = 'TestCapsuleName'; - private const CAPSULE_DIR_PATH = self::TEST_DIR_PATH . self::CAPSULE_NAME; - private const XML_FILE_PATH = self::CAPSULE_DIR_PATH . '/file/project.xml'; protected function setUp(): void { @@ -59,34 +56,35 @@ class ProjectControllerTest extends WebTestCase $file_system->remove(self::TEST_DIR_PATH . self::CAPSULE_NAME); $capsule_repository = $this->object_manager->getRepository(Capsule::class); - $last_capsule = $capsule_repository->findOneBy(['name' => self::CAPSULE_NAME]); + $detached_last_capsule = $capsule_repository->findOneBy(['name' => self::CAPSULE_NAME]); - if (! $last_capsule instanceof Capsule) { + if (! $detached_last_capsule instanceof Capsule) { throw new \Exception("Capsule does not exist."); } + $last_capsule = $this->object_manager->merge($detached_last_capsule); $this->object_manager->remove($last_capsule); $this->object_manager->flush(); } - /** @phpstan-ignore-next-line */ + /** @phpstan-ignore-next-line */ private function getDOMDocument(string $capsule_directory): \DOMDocument { $dom_xml = new \DOMDocument(); $dom_xml->preserveWhiteSpace = false; - $dom_xml->load($this->createXmlFilePath($capsule_directory)); + $dom_xml->load($this->getXmlFilePath($capsule_directory)); return $dom_xml; } - private function createCapsuleDirPath(string $capsule_directory): string + private function getCapsuleDirPath(string $capsule_directory): string { return self::TEST_DIR_PATH . $capsule_directory; } - private function createXmlFilePath(string $capsule_directory): string + private function getXmlFilePath(string $capsule_directory): string { - return $this->createCapsuleDirPath($capsule_directory) . '/file/project.xml'; + return $this->getCapsuleDirPath($capsule_directory) . '/file/project.xml'; } public function testProjectDirectoryWithCorrespondingXMLFileIsCreatedWhenCapsuleCreationIsSuccessful(): void -- GitLab