48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Controller;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
|
|
class ConferenceControllerTest extends WebTestCase
|
|
{
|
|
public function testIndex()
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/');
|
|
|
|
$this->assertResponseIsSuccessful();
|
|
$this->assertSelectorTextContains('h2', 'Give your feedback');
|
|
}
|
|
|
|
public function testConferencePage()
|
|
{
|
|
$client = static::createClient();
|
|
$crawler = $client->request('GET', '/');
|
|
|
|
$this->assertCount(2, $crawler->filter('h4'));
|
|
|
|
$client->clickLink('View');
|
|
|
|
$this->assertPageTitleContains('Amsterdam');
|
|
$this->assertResponseIsSuccessful();
|
|
$this->assertSelectorTextContains('h2', 'Amsterdam 2019');
|
|
$this->assertSelectorExists('div:contains("There are 1 comments")');
|
|
}
|
|
|
|
public function testCommentSubmission()
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', 'conference/amsterdam-2019');
|
|
$client->submitForm('Submit', [
|
|
'comment[author]' => 'Bob',
|
|
'comment[text]' => 'Some feedback from an automated functional test',
|
|
'comment[email]' => 'test@example.com',
|
|
'comment[photo]' => dirname(__DIR__, 2) . '/public/images/under-construction.gif',
|
|
]);
|
|
$this->assertResponseRedirects();
|
|
$client->followRedirect();
|
|
$this->assertSelectorExists('div:contains("There are 2 comments")');
|
|
}
|
|
}
|