try to fix userRenderTest: mock not working

This commit is contained in:
Julie Lenaerts 2024-02-12 14:36:41 +01:00
parent f510acd170
commit 1b96deb4ee

View File

@ -2,7 +2,6 @@
namespace Templating\Entity;
use Chill\ActivityBundle\Entity\Activity;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserJob;
@ -10,12 +9,21 @@ use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Clock\MockClock;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
class UserRenderTest extends TestCase
class UserRenderTest extends WebTestCase
{
use ProphecyTrait;
public function setUp(): void
{
self::bootKernel();
}
public function testRenderUserWithJobAndScopeAtCertainDate(): void
{
// Create a user with a certain user job
@ -63,12 +71,14 @@ class UserRenderTest extends TestCase
$user->getUserScopeHistories()->add($userScopeHistoryB);
// Create renderer
$translatableStringHelper = $this->createMock(TranslatableStringHelperInterface::class);
$engine = $this->createMock(Environment::class);
$translator = $this->createMock(TranslatorInterface::class);
$translatableStringHelperMock = $this->getMockBuilder(TranslatableStringHelperInterface::class)
->getMock();
$engineMock = $this->createMock(Environment::class);
$translatorMock = $this->createMock(TranslatorInterface::class);
$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;
$options['at_date'] = new \DateTime('2023-11-25 12:00:00');