Commit b096e457 authored by BuildTools's avatar BuildTools
Browse files

finish fixtures and Event Course test

parent f47532d6
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "89db0297dc16f4ceb8948c2f448e2410",
"content-hash": "9e8b58caa51be3dac3fb6ee3061640b2",
"packages": [
{
"name": "composer/package-versions-deprecated",
......@@ -153,16 +153,16 @@
},
{
"name": "doctrine/cache",
"version": "1.11.0",
"version": "1.11.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "a9c1b59eba5a08ca2770a76eddb88922f504e8e0"
"reference": "163074496dc7c3c7b8ccbf3d4376c0187424ed81"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/a9c1b59eba5a08ca2770a76eddb88922f504e8e0",
"reference": "a9c1b59eba5a08ca2770a76eddb88922f504e8e0",
"url": "https://api.github.com/repos/doctrine/cache/zipball/163074496dc7c3c7b8ccbf3d4376c0187424ed81",
"reference": "163074496dc7c3c7b8ccbf3d4376c0187424ed81",
"shasum": ""
},
"require": {
......@@ -232,7 +232,7 @@
],
"support": {
"issues": "https://github.com/doctrine/cache/issues",
"source": "https://github.com/doctrine/cache/tree/1.11.0"
"source": "https://github.com/doctrine/cache/tree/1.11.1"
},
"funding": [
{
......@@ -248,7 +248,7 @@
"type": "tidelift"
}
],
"time": "2021-04-13T14:46:17+00:00"
"time": "2021-05-18T16:45:32+00:00"
},
{
"name": "doctrine/collections",
......@@ -1609,22 +1609,22 @@
},
{
"name": "friendsofphp/proxy-manager-lts",
"version": "v1.0.3",
"version": "v1.0.4",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/proxy-manager-lts.git",
"reference": "121af47c9aee9c03031bdeca3fac0540f59aa5c3"
"reference": "587bfddfd9847c1d0417c4cf07d1dbf19aa6d136"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/proxy-manager-lts/zipball/121af47c9aee9c03031bdeca3fac0540f59aa5c3",
"reference": "121af47c9aee9c03031bdeca3fac0540f59aa5c3",
"url": "https://api.github.com/repos/FriendsOfPHP/proxy-manager-lts/zipball/587bfddfd9847c1d0417c4cf07d1dbf19aa6d136",
"reference": "587bfddfd9847c1d0417c4cf07d1dbf19aa6d136",
"shasum": ""
},
"require": {
"laminas/laminas-code": "~3.4.1|^4.0",
"php": ">=7.1",
"symfony/filesystem": "^4.4.17|^5.0"
"symfony/filesystem": "^4.4.17|^5.0|^6.0"
},
"conflict": {
"laminas/laminas-stdlib": "<3.2.1",
......@@ -1635,7 +1635,7 @@
},
"require-dev": {
"ext-phar": "*",
"symfony/phpunit-bridge": "^5.2"
"symfony/phpunit-bridge": "^5.2|^6.0"
},
"type": "library",
"extra": {
......@@ -1675,7 +1675,7 @@
],
"support": {
"issues": "https://github.com/FriendsOfPHP/proxy-manager-lts/issues",
"source": "https://github.com/FriendsOfPHP/proxy-manager-lts/tree/v1.0.3"
"source": "https://github.com/FriendsOfPHP/proxy-manager-lts/tree/v1.0.4"
},
"funding": [
{
......@@ -1687,7 +1687,7 @@
"type": "tidelift"
}
],
"time": "2021-01-14T21:52:44+00:00"
"time": "2021-05-19T14:35:49+00:00"
},
{
"name": "laminas/laminas-code",
......@@ -4055,16 +4055,16 @@
},
{
"name": "symfony/flex",
"version": "v1.12.2",
"version": "v1.13.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/flex.git",
"reference": "e472606b4b3173564f0edbca8f5d32b52fc4f2c9"
"reference": "2597d0dda8042c43eed44a9cd07236b897e427d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/flex/zipball/e472606b4b3173564f0edbca8f5d32b52fc4f2c9",
"reference": "e472606b4b3173564f0edbca8f5d32b52fc4f2c9",
"url": "https://api.github.com/repos/symfony/flex/zipball/2597d0dda8042c43eed44a9cd07236b897e427d7",
"reference": "2597d0dda8042c43eed44a9cd07236b897e427d7",
"shasum": ""
},
"require": {
......@@ -4081,7 +4081,7 @@
"type": "composer-plugin",
"extra": {
"branch-alias": {
"dev-main": "1.12-dev"
"dev-main": "1.13-dev"
},
"class": "Symfony\\Flex\\Flex"
},
......@@ -4103,7 +4103,7 @@
"description": "Composer plugin for Symfony",
"support": {
"issues": "https://github.com/symfony/flex/issues",
"source": "https://github.com/symfony/flex/tree/v1.12.2"
"source": "https://github.com/symfony/flex/tree/v1.13.3"
},
"funding": [
{
......@@ -4119,7 +4119,7 @@
"type": "tidelift"
}
],
"time": "2021-02-16T14:05:05+00:00"
"time": "2021-05-19T07:19:15+00:00"
},
{
"name": "symfony/form",
......@@ -10239,16 +10239,16 @@
},
{
"name": "symfony/phpunit-bridge",
"version": "v5.2.8",
"version": "v5.2.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/phpunit-bridge.git",
"reference": "b3cf2c3f7f6196fb498002920c1ae9036d9e5619"
"reference": "ea24e42c1ee04792f5d814da6f0814b20ece2907"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/b3cf2c3f7f6196fb498002920c1ae9036d9e5619",
"reference": "b3cf2c3f7f6196fb498002920c1ae9036d9e5619",
"url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/ea24e42c1ee04792f5d814da6f0814b20ece2907",
"reference": "ea24e42c1ee04792f5d814da6f0814b20ece2907",
"shasum": ""
},
"require": {
......@@ -10302,7 +10302,7 @@
"description": "Provides utilities for PHPUnit, especially user deprecation notices management",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/phpunit-bridge/tree/v5.2.8"
"source": "https://github.com/symfony/phpunit-bridge/tree/v5.2.9"
},
"funding": [
{
......@@ -10318,7 +10318,7 @@
"type": "tidelift"
}
],
"time": "2021-05-07T12:56:09+00:00"
"time": "2021-05-16T13:07:46+00:00"
},
{
"name": "symfony/profiler-pack",
......
......@@ -14,16 +14,19 @@ class ParticipantMakeEventCourseFixtures extends Fixture implements DependentFix
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::LUC_CHAMPIONSHIP_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::SULIAC_Championship_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::SULIAC_LUC_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::LUC_CHAMPIONSHIP_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::ERIC_Championship_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::ERIC_LUC_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::AUBIN_CHAMPIONSHIP_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::SULIAC_Championship_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::SULIAC_AUBIN_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
......@@ -35,16 +38,19 @@ class ParticipantMakeEventCourseFixtures extends Fixture implements DependentFix
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::LUC_POINTS_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::SULIAC_Points_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::SULIAC_LUC_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::LUC_POINTS_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::ERIC_Points_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::ERIC_LUC_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::AUBIN_POINTS_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::SULIAC_Points_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::SULIAC_AUBIN_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
......@@ -56,16 +62,19 @@ class ParticipantMakeEventCourseFixtures extends Fixture implements DependentFix
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::LUC_CUMULATED_TIME_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::SULIAC_Cumulated_Time_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::SULIAC_LUC_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::LUC_CUMULATED_TIME_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::ERIC_Cumulated_Time_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::ERIC_LUC_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
$participantMakeEventCourse->setEventCourse($this->getReference(EventCourseFixtures::AUBIN_CUMULATED_TIME_EVENTCOURSE_REFERENCE));
$participantMakeEventCourse->setParticipant($this->getReference(ParticipantFixtures::SULIAC_Cumulated_Time_Participant_REFERENCE));
$participantMakeEventCourse->setTrack($this->getReference(TrackFixtures::SULIAC_AUBIN_TRACK_REFERENCE));
$manager->persist($participantMakeEventCourse);
$participantMakeEventCourse = new ParticipantMakeEventCourse();
......
......@@ -151,10 +151,10 @@ class EventCourse
}
}
public function remove(ObjectManager $entityManager, ParticipantMakeEventCourseRepository $participantMakeEventCourse)
public function remove(ObjectManager $entityManager, ParticipantMakeEventCourseRepository $participantMakeEventCourseRepository)
{
foreach ($this->event->getParticipants() as $participant) {
$participantMakeEventCourse->find(array("eventCourse" => $this, "participant" => $participant))->remove($entityManager);
$participantMakeEventCourseRepository->find(array("eventCourse" => $this, "participant" => $participant))->remove($entityManager);
}
$entityManager->remove($this);
$entityManager->flush();
......
......@@ -5,14 +5,57 @@ namespace App\Tests\Entity;
use App\Entity\EventCourse;
use App\Entity\ParticipantMakeEventCourse;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class EventCourseTest extends TestCase
class EventCourseTest extends KernelTestCase
{
/**
* @var \Doctrine\ORM\EntityManager
*/
private $entityManager;
protected function setUp(): void
{
$kernel = self::bootKernel();
$this->entityManager = $kernel->getContainer()
->get('doctrine')
->getManager();
}
public function testConvertTimeToMaxTime(){
$eventCourse = new EventCourse();
$eventCourse->setTime(1000);
$eventCourse->convertTimeToMaxTime();
$this->assertEquals(1000000,$eventCourse->getMaxTime());
}
public function testRemove(){
$eventCourse=$this->entityManager->getRepository(EventCourse::class)->findAll()[0];
$nbParticipantMakeEventCourse = count($this->entityManager->getRepository(ParticipantMakeEventCourse::class)->findAll());
$eventCourse->remove($this->entityManager, $this->entityManager->getRepository(ParticipantMakeEventCourse::class));
$this->assertSame($nbParticipantMakeEventCourse, count($this->entityManager->getRepository(ParticipantMakeEventCourse::class)->findAll())+2);
}
public function testGenerateParticipantMakeEventCourse(){
$nbParticipantMakeEventCourse = count($this->entityManager->getRepository(ParticipantMakeEventCourse::class)->findAll());
$eventCourse=$this->entityManager->getRepository(EventCourse::class)->findAll()[0];
$event = $eventCourse->getEvent();
$participant1 = $eventCourse->getEvent()->getParticipants()[0];
$participant2 = $eventCourse->getEvent()->getParticipants()[1];
$this->entityManager->getRepository(ParticipantMakeEventCourse::class)->find(array("eventCourse" => $eventCourse, "participant" => $participant1))->remove($this->entityManager);
$this->entityManager->getRepository(ParticipantMakeEventCourse::class)->find(array("eventCourse" => $eventCourse, "participant" => $participant2))->remove($this->entityManager);
$eventCourse->generateParticipantMakeEventCourse($this->entityManager);
$this->assertSame($nbParticipantMakeEventCourse, count($this->entityManager->getRepository(ParticipantMakeEventCourse::class)->findAll()));
}
protected function tearDown(): void
{
parent::tearDown();
$this->entityManager->close();
$this->entityManager = null;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment