mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
AuthorizationHelper: compare center and scope based on id, not on equality
For an unknown reason, in some circumstances, the use of the `===` comparator does not work when comparing Center instances and Scope instances. Then, we compare them based on the id.
This commit is contained in:
@@ -11,6 +11,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Test;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
|
||||
/**
|
||||
* A trait to prepare center.
|
||||
*
|
||||
@@ -25,23 +27,17 @@ trait PrepareCenterTrait
|
||||
|
||||
/**
|
||||
* prepare a mocked center, with and id and name given.
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Center
|
||||
*/
|
||||
protected function prepareCenter($id, $name)
|
||||
protected function prepareCenter(int $id, string $name): Center
|
||||
{
|
||||
if (null === $this->centerProphet) {
|
||||
$this->centerProphet = new \Prophecy\Prophet();
|
||||
}
|
||||
$center = new Center();
|
||||
$center->setName($name);
|
||||
|
||||
$center = $this->centerProphet->prophesize();
|
||||
$center->willExtend('\\' . \Chill\MainBundle\Entity\Center::class);
|
||||
$center->getId()->willReturn($id);
|
||||
$center->getName()->willReturn($name);
|
||||
$reflectionClass = new \ReflectionClass($center);
|
||||
$reflectionId = $reflectionClass->getProperty('id');
|
||||
$reflectionId->setAccessible(true);
|
||||
$reflectionId->setValue($center, $id);
|
||||
|
||||
return $center->reveal();
|
||||
return $center;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user