merge conflicts resolved

This commit is contained in:
Julie Lenaerts 2022-02-14 14:55:47 +01:00
commit df61fbff12
4 changed files with 23 additions and 11 deletions

View File

@ -259,6 +259,7 @@ and this project adheres to
* add an endpoint for checking permissions. See https://gitlab.com/Chill-Projet/chill-bundles/-/merge_requests/232 * add an endpoint for checking permissions. See https://gitlab.com/Chill-Projet/chill-bundles/-/merge_requests/232
* [activity] for a new activity: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties * [activity] for a new activity: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties
* [calendar] for a new rdv: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties * [calendar] for a new rdv: suggest and create on-the-fly locations based on the accompanying course location + location of the suggested parties
* [period] Validation added when period is confidential and confirmed -> user cannot be null.
## Test releases ## Test releases

BIN
composer Executable file

Binary file not shown.

View File

@ -500,6 +500,20 @@ class AccompanyingPeriod implements
return end($periods) === $this; return end($periods) === $this;
} }
/**
* @Assert\Callback
*/
public function canUserBeNull(ExecutionContextInterface $context)
{
if ($this->getStep() === self::STEP_CONFIRMED && $this->isConfidential() === true) {
if (!$this->getUser()) {
$context->buildViolation('User cannot be null for an accompanying period that is confirmed and confidential')
->atPath('user')
->addViolation();
}
}
}
/** /**
* Close a participation for a person. * Close a participation for a person.
* *
@ -938,7 +952,7 @@ class AccompanyingPeriod implements
} }
/** /**
* Validation function. * Validation functions.
*/ */
public function isDateConsistent(ExecutionContextInterface $context) public function isDateConsistent(ExecutionContextInterface $context)
{ {

View File

@ -11,11 +11,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\AccompanyingPeriod; namespace Chill\PersonBundle\Tests\AccompanyingPeriod;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Validator\Validator\ValidatorInterface;
/** /**
* @internal * @internal
@ -42,7 +43,7 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase
]); ]);
} }
public function dataGenerateRandomAccompanyingCourse() public function testConfidentialInvalid()
{ {
// Disabling this dataprovider to avoid having errors while running the test. // Disabling this dataprovider to avoid having errors while running the test.
return yield from []; return yield from [];
@ -88,10 +89,7 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase
} }
} }
/** public function testConfidentialValid()
* @dataProvider dataGenerateRandomAccompanyingCourse
*/
public function testRemoveUserWhenConfidential(int $periodId)
{ {
$this->markTestIncomplete( $this->markTestIncomplete(
'Marked as incomplete because of a problem in the dataprovider, at line 81.' 'Marked as incomplete because of a problem in the dataprovider, at line 81.'
@ -101,8 +99,7 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase
->find($periodId); ->find($periodId);
$em = self::$kernel->getContainer()->get('doctrine.orm.entity_manager'); $em = self::$kernel->getContainer()->get('doctrine.orm.entity_manager');
$isConfidential = $period->isConfidential(); $violations = self::$validator->validate($period, null, ['confirmed']);
$step = $period->getStep();
$initialUser = $period->getUser(); $initialUser = $period->getUser();