Created
January 25, 2019 11:50
-
-
Save ollo-ride-nico/fffa47247fa8faae4b481efca3b003b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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