2026-06-02 18:53:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Tests\Integration\Controller;
|
|
|
|
|
|
2026-06-02 22:01:42 +02:00
|
|
|
use App\Entity\Restaurant;
|
2026-06-02 23:39:23 +02:00
|
|
|
use App\Factory\RestaurantFactory;
|
2026-06-02 22:01:42 +02:00
|
|
|
use App\Repository\SubjectRepository;
|
2026-06-02 18:53:17 +02:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
|
|
|
|
2026-06-02 20:30:18 +02:00
|
|
|
class SubjectControllerTest extends WebTestCase
|
2026-06-02 18:53:17 +02:00
|
|
|
{
|
2026-06-02 23:39:23 +02:00
|
|
|
public function testSubjectList(): void
|
|
|
|
|
{
|
|
|
|
|
$client = static::createClient();
|
|
|
|
|
|
|
|
|
|
$subject = RestaurantFactory::createOne();
|
|
|
|
|
|
|
|
|
|
$client->request('GET', '/');
|
|
|
|
|
|
|
|
|
|
$this->assertSelectorTextContains('ul li', $subject->getName());
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-02 22:01:42 +02:00
|
|
|
public function testAddingNewSubject(): void
|
2026-06-02 18:53:17 +02:00
|
|
|
{
|
|
|
|
|
$client = static::createClient();
|
|
|
|
|
$crawler = $client->request('GET', '/');
|
|
|
|
|
|
2026-06-02 22:01:42 +02:00
|
|
|
$client->submitForm('form_save', ['form[name]' => 'Riviera']);
|
|
|
|
|
|
|
|
|
|
$this->assertResponseRedirects();
|
|
|
|
|
|
2026-06-02 23:39:23 +02:00
|
|
|
$crawler = $client->followRedirect();
|
|
|
|
|
|
2026-06-02 22:01:42 +02:00
|
|
|
$subject = static::getContainer()
|
|
|
|
|
->get(SubjectRepository::class)
|
|
|
|
|
->findOneBy(['name' => 'Riviera']);
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($subject);
|
|
|
|
|
$this->assertInstanceOf(Restaurant::class, $subject);
|
2026-06-02 23:39:23 +02:00
|
|
|
|
|
|
|
|
$this->assertSelectorTextContains('ul li', 'Riviera');
|
2026-06-02 18:53:17 +02:00
|
|
|
}
|
|
|
|
|
}
|