mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
try to fix userRenderTest: mock not working
This commit is contained in:
parent
f510acd170
commit
1b96deb4ee
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Templating\Entity;
|
namespace Templating\Entity;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Entity\UserJob;
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
@ -10,12 +9,21 @@ use Chill\MainBundle\Templating\Entity\UserRender;
|
|||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
use Symfony\Component\Clock\MockClock;
|
use Symfony\Component\Clock\MockClock;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
class UserRenderTest extends TestCase
|
class UserRenderTest extends WebTestCase
|
||||||
{
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
public function testRenderUserWithJobAndScopeAtCertainDate(): void
|
public function testRenderUserWithJobAndScopeAtCertainDate(): void
|
||||||
{
|
{
|
||||||
// Create a user with a certain user job
|
// Create a user with a certain user job
|
||||||
@ -63,12 +71,14 @@ class UserRenderTest extends TestCase
|
|||||||
$user->getUserScopeHistories()->add($userScopeHistoryB);
|
$user->getUserScopeHistories()->add($userScopeHistoryB);
|
||||||
|
|
||||||
// Create renderer
|
// Create renderer
|
||||||
$translatableStringHelper = $this->createMock(TranslatableStringHelperInterface::class);
|
$translatableStringHelperMock = $this->getMockBuilder(TranslatableStringHelperInterface::class)
|
||||||
$engine = $this->createMock(Environment::class);
|
->getMock();
|
||||||
$translator = $this->createMock(TranslatorInterface::class);
|
|
||||||
|
$engineMock = $this->createMock(Environment::class);
|
||||||
|
$translatorMock = $this->createMock(TranslatorInterface::class);
|
||||||
$clock = new MockClock(new \DateTimeImmutable('2023-12-15 12:00:00'));
|
$clock = new MockClock(new \DateTimeImmutable('2023-12-15 12:00:00'));
|
||||||
|
|
||||||
$renderer = new UserRender($translatableStringHelper, $engine, $translator, $clock);
|
$renderer = new UserRender($translatableStringHelperMock, $engineMock, $translatorMock, $clock);
|
||||||
|
|
||||||
$optionsNoDate['at_date'] = null;
|
$optionsNoDate['at_date'] = null;
|
||||||
$options['at_date'] = new \DateTime('2023-11-25 12:00:00');
|
$options['at_date'] = new \DateTime('2023-11-25 12:00:00');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user