chill-bundles/src/Bundle/ChillMainBundle/Test/PrepareCircleTrait.php

48 lines
1.1 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;
/**
* 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();
}
}