diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/CenterControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/CenterControllerTest.php index 8699ceba1..1500e430f 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/CenterControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/CenterControllerTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Tests\Controller; +use Chill\MainBundle\Test\PrepareClientTrait; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** @@ -19,59 +20,25 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class CenterControllerTest extends WebTestCase { - public function testCompleteScenario() + + use PrepareClientTrait; + + /** + * This is a smoke test that ensure that the list page does show + */ + public function testCenterAdminSmokeTest(): void { - // Create a new client to browse the application - $client = self::createClient([], [ - 'PHP_AUTH_USER' => 'admin', - 'PHP_AUTH_PW' => 'password', - 'HTTP_ACCEPT_LANGUAGE' => 'fr_FR', - ]); + $client = $this->getClientAuthenticated('admin', 'password'); - // 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()); + $crawler = $client->request('GET', '/fr/admin/center'); + self::assertResponseIsSuccessful("Test that /fr/admin/center does show"); - // Fill in the form and submit it - $form = $crawler->selectButton('Créer')->form([ - 'chill_mainbundle_center[name]' => 'Test center', - ]); + $btnEdit = $crawler->filter('.btn-edit')?->first(); - $client->submit($form); - $crawler = $client->followRedirect(); + self::assertNotNull($btnEdit, "check that there is at least one btn-edit on center page"); - // Check data in the show view - $this->assertGreaterThan( - 0, - $crawler->filter('td:contains("Test center")')->count(), - 'Missing element td:contains("Test center")' - ); + $client->click($btnEdit->link()); - // 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()); + self::assertResponseIsSuccessful(); } }