mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-14 05:11:23 +00:00
The update modifies several test classes within the "chill-project" to change non-static class-level variables and methods to static ones. This change has been made to improve readability, performance, and to eliminate unnecessary instantiation of class objects in test scenarios. Also, flush and clear actions on the entity manager are moved to individual data providers.
44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?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;
|
|
|
|
use Chill\MainBundle\Entity\Scope;
|
|
|
|
/**
|
|
* A trait to prepare center.
|
|
*
|
|
* **Usage :** You must set up trait with `setUpTrait` before use
|
|
* and use tearDownTrait after usage.
|
|
*
|
|
* @codeCoverageIgnore
|
|
*/
|
|
trait PrepareScopeTrait
|
|
{
|
|
/**
|
|
* prepare a mocked scope, with and id and name given.
|
|
*
|
|
* The name will be present in both lang `fr` and `en`.
|
|
*/
|
|
protected static function prepareScope(int $id, string $name): Scope
|
|
{
|
|
$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;
|
|
}
|
|
}
|