78 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
* @coversNothing
*/
final class CenterControllerTest extends WebTestCase
{
public function testCompleteScenario()
{
// Create a new client to browse the application
$client = self::createClient([], [
'PHP_AUTH_USER' => 'admin',
'PHP_AUTH_PW' => 'password',
'HTTP_ACCEPT_LANGUAGE' => 'fr_FR',
]);
// Create a new entry in the database
$crawler = $client->request('GET', '/fr/admin/center/');
$this->assertEquals(
200,
$client->getResponse()->getStatusCode(),
'Unexpected HTTP status code for GET /fr/admin/center/'
);
$crawler = $client->click($crawler->selectLink('Créer un nouveau centre')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Créer')->form([
'chill_mainbundle_center[name]' => 'Test center',
]);
$client->submit($form);
$crawler = $client->followRedirect();
// Check data in the show view
$this->assertGreaterThan(
0,
$crawler->filter('td:contains("Test center")')->count(),
'Missing element td:contains("Test center")'
);
// Edit the entity
$crawler = $client->click($crawler->selectLink('modifier')->link());
$form = $crawler->selectButton('Mettre à jour')->form([
'chill_mainbundle_center[name]' => 'Foo',
]);
$client->submit($form);
$crawler = $client->followRedirect();
// Check the element contains an attribute with value equals "Foo"
$this->assertGreaterThan(
0,
$crawler->filter('[value="Foo"]')->count(),
'Missing element [value="Foo"]'
);
$crawler = $client->request('GET', '/fr/admin/center/');
// Check the entity has been delete on the list
$this->assertMatchesRegularExpression('/Foo/', $client->getResponse()->getContent());
}
}