mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-05 07:19:49 +00:00
attempt to write tests
This commit is contained in:
parent
d6b1216021
commit
4a58d7f300
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Dashboard;
|
||||
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class NewsItemControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* Test to ensure that the news item admin index page works.
|
||||
*/
|
||||
public function newsItemAdminSmokeTest(): void
|
||||
{
|
||||
$client = $this->getClientAuthenticated('admin', 'admin');
|
||||
|
||||
$crawler = $client->request('GET', '/fr/admin/news_item');
|
||||
self::assertResponseIsSuccessful('Testing /fr/admin/news_item');
|
||||
|
||||
$btnEdit = $crawler->filter('.btn-edit')?->first();
|
||||
|
||||
self::assertNotNull($btnEdit, 'check that there is at least one btn-edit on news item page');
|
||||
|
||||
$client->click($btnEdit->link());
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Dashboard;
|
||||
|
||||
use Chill\MainBundle\Entity\NewsItem;
|
||||
use Chill\MainBundle\Repository\NewsItemRepository;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Clock\MockClock;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class NewsItemRepositoryTest extends KernelTestCase
|
||||
{
|
||||
private NewsItemRepository $newsItemRepository;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
self::bootKernel();
|
||||
$this->newsItemRepository = self::$container->get(NewsItemRepository::class);
|
||||
}
|
||||
|
||||
public function testFindWithDateFilter(): void
|
||||
{
|
||||
$clock = new MockClock('2023-11-20');
|
||||
|
||||
$newsItemA = new NewsItem();
|
||||
$newsItemA->setTitle('With end date article');
|
||||
$newsItemA->setContent('blabla');
|
||||
$newsItemA->setStartDate(new \DateTime('2023-11-01'));
|
||||
$newsItemA->setEndDate(new \DateTime('2023-11-15'));
|
||||
|
||||
$newsItemB = new NewsItem();
|
||||
$newsItemB->setTitle('No end date article');
|
||||
$newsItemB->setContent('with blopblop');
|
||||
$newsItemB->setStartDate(new \DateTime('2023-11-02'));
|
||||
|
||||
$newsItemC = new NewsItem();
|
||||
$newsItemC->setTitle('Null as end date article');
|
||||
$newsItemC->setContent('tralala');
|
||||
$newsItemC->setStartDate(new \DateTime('2023-11-03'));
|
||||
$newsItemC->setEndDate(null);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user