feat: Ajoute HomeController et son test
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
</exclude>
|
||||
|
||||
|
||||
<deprecationTrigger>
|
||||
|
||||
18
src/Controller/HomeController.php
Normal file
18
src/Controller/HomeController.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class HomeController extends AbstractController
|
||||
{
|
||||
|
||||
#[Route(path: '/',name: 'toot',methods: 'GET')]
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return$this->json([]);
|
||||
|
||||
}
|
||||
}
|
||||
23
tests/Controller/HomeControllerTest.php
Normal file
23
tests/Controller/HomeControllerTest.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class HomeControllerTest extends WebTestCase
|
||||
{
|
||||
public function testIndex(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
// Request a specific page
|
||||
$crawler = $client->request('GET', '/');
|
||||
|
||||
// Validate a successful response and some content
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertResponseHeaderSame('Content-Type', 'application/json');
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user