Skip to content
Snippets Groups Projects
Commit 06d698c4 authored by Camille Simiand's avatar Camille Simiand Committed by Sebastien
Browse files

Rebase and fix errors

parent 0a4410b1
No related branches found
No related tags found
3 merge requests!43tuleap-83-access-my-capsules,!42Draft: access-my-capsules-conflicts-fixed,!40Draft: Tuleap 83 access my capsules
......@@ -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;
}
}
......@@ -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,12 +56,13 @@ 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();
}
......@@ -74,19 +72,19 @@ class ProjectControllerTest extends WebTestCase
{
$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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment