chill-bundles/src/Bundle/ChillMainBundle/Test/PrepareCenterTrait.php
2021-11-30 13:54:58 +01:00

48 lines
1.1 KiB
PHP

<?php
/**
* 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.
*/
declare(strict_types=1);
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 PrepareCenterTrait
{
private $centerProphet;
/**
* 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)
{
if (null === $this->centerProphet) {
$this->centerProphet = new \Prophecy\Prophet();
}
$center = $this->centerProphet->prophesize();
$center->willExtend('\Chill\MainBundle\Entity\Center');
$center->getId()->willReturn($id);
$center->getName()->willReturn($name);
return $center->reveal();
}
}