Skip to content

Instantly share code, notes, and snippets.

@ollo-ride-nico
Created January 25, 2019 11:50
Show Gist options
  • Save ollo-ride-nico/fffa47247fa8faae4b481efca3b003b1 to your computer and use it in GitHub Desktop.
Save ollo-ride-nico/fffa47247fa8faae4b481efca3b003b1 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by Nicolas Dirollo.
* Date: 17/01/2019
* Time: 15:51
* @package Symfony
* @author Nicolas Dirollo
* @copyright 2019 ND
* @license *
*/
namespace Tests\AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Tests\AppBundle\Traits\AuthenticationTrait;
class CreateUserControllerTest extends WebTestCase
{
use AuthenticationTrait;
public function testCreateUser()
{
$client = $this->logIn();
// Request the route
$crawler = $client->request('GET', '/users/create');
// Test
$this->assertEquals(
1,
$crawler->filter('form')->count()
);
$this->assertTrue($client->getResponse()->isSuccessful());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
// Select the form
$form = $crawler->selectButton('Ajouter')->form();
// set some values
$form['user[username]'] = 'Thomas';
$form['user[password][first]'] = 'pass';
$form['user[password][second]'] = 'pass';
$form['user[email]'] = '[email protected]';
$form['user[role]'] = 'ROLE_USER';
// submit the form
$crawler = $client->submit($form);
//$this->assertSame(1, $crawler->filter('div.alert.alert-success')->count());
// Test
//$this->assertTrue($this->client->getResponse()->isRedirect());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment