mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
work on tests
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?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 Controller;
|
||||
|
||||
use Chill\MainBundle\Entity\NewsItem;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* Tests the admin pages for news items
|
||||
*
|
||||
*/
|
||||
class NewsItemControllerTest extends WebTestCase
|
||||
{
|
||||
use PrepareClientTrait;
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
public function generateNewsItemIds(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$newsItems = $qb->select('n')->from(NewsItem::class, 'n')
|
||||
->setMaxResults(2)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
foreach ($newsItems as $n) {
|
||||
yield [$n->getId()];
|
||||
}
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
}
|
||||
|
||||
public function testList()
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
$client->request('GET', "/fr/admin/news_item");
|
||||
|
||||
self::assertResponseIsSuccessful('Test that news item admin page shows');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateNewsItemIds
|
||||
*/
|
||||
public function testShowSingleItem(int $newsItemId)
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
$client->request('GET', "/fr/amdin/news_item/{$newsItemId}/view");
|
||||
|
||||
$this->assertResponseIsSuccessful('test that single news item admin page loads successfully');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user