Fix: AuthorizationHelperTest: remove deprecated and deprecation of PrepareScopeTrait

This commit is contained in:
2023-07-27 23:51:57 +02:00
parent dba1d0548e
commit 5f6e506300
3 changed files with 29 additions and 94 deletions

View File

@@ -1,47 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Test;
/**
* A trait to prepare center.
*
* **Usage :** You must set up trait with `setUpTrait` before use
* and use tearDownTrait after usage.
*
* @codeCoverageIgnore
*/
trait PrepareCircleTrait
{
private $circleProphet;
/**
* prepare a mocked center, with and id and name given.
*
* @param int $id
* @param string $name
*
* @return \Chill\MainBundle\Entity\Center
*/
protected function prepareCircle($id, $name)
{
if (null === $this->circleProphet) {
$this->circleProphet = new \Prophecy\Prophet();
}
$scope = $this->circleProphet->prophesize();
$scope->willExtend('\\' . \Chill\MainBundle\Entity\Scope::class);
$scope->getId()->willReturn($id);
$scope->getName()->willReturn($name);
return $scope->reveal();
}
}

View File

@@ -11,6 +11,8 @@ declare(strict_types=1);
namespace Chill\MainBundle\Test;
use Chill\MainBundle\Entity\Scope;
/**
* A trait to prepare center.
*
@@ -18,25 +20,24 @@ namespace Chill\MainBundle\Test;
* and use tearDownTrait after usage.
*
* @codeCoverageIgnore
*
* @deprecated use PrepareCircleTrait instead
*/
trait PrepareScopeTrait
{
use PrepareCircleTrait;
/**
* prepare a mocked center, with and id and name given.
* prepare a mocked scope, with and id and name given.
*
* @param int $id
* @param string $name
*
* @return \Chill\MainBundle\Entity\Center
*
* @deprecated
* The name will be present in both lang `fr` and `en`.
*/
protected function prepareScope($id, $name)
protected function prepareScope(int $id, string $name): Scope
{
return $this->prepareCircle($id, $name);
$scope = new Scope();
// set the name
$scope->setName(['fr' => $name, 'en' => $name]);
$reflection = new \ReflectionClass($scope);
$idProperty = $reflection->getProperty('id');
$idProperty->setAccessible(true);
$idProperty->setValue($scope, $id);
return $scope;
}
}