43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Integration\Controller;
|
|
|
|
use App\Entity\Restaurant;
|
|
use App\Factory\RestaurantFactory;
|
|
use App\Repository\SubjectRepository;
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
|
|
class SubjectControllerTest extends WebTestCase
|
|
{
|
|
public function testSubjectList(): void
|
|
{
|
|
$client = static::createClient();
|
|
|
|
$subject = RestaurantFactory::createOne();
|
|
|
|
$client->request('GET', '/');
|
|
|
|
$this->assertSelectorTextContains('ul li', $subject->getName());
|
|
}
|
|
|
|
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');
|
|
}
|
|
}
|