rater/tests/Integration/Subject/AddSubjectTest.php
2026-06-02 22:29:21 +00:00

31 lines
829 B
PHP

<?php
namespace App\Tests\Integration\Subject;
use App\Entity\Restaurant;
use App\Repository\SubjectRepository;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class AddSubjectTest extends WebTestCase
{
public function testAddingNewSubject(): void
{
$client = static::createClient();
$crawler = $client->request('GET', '/');
$client->submitForm('form_save', ['form[name]' => 'Riviera']);
$this->assertResponseRedirects();
$crawler = $client->followRedirect();
$subject = static::getContainer()
->get(SubjectRepository::class)
->findOneBy(['name' => 'Riviera']);
$this->assertNotNull($subject);
$this->assertInstanceOf(Restaurant::class, $subject);
$this->assertSelectorTextContains('ul li', 'Riviera');
}
}