<commit_before><?php
/**
 * Created by PhpStorm.
 * User: apf
 * Date: 28/10/15
 * Time: 21:38
 */

namespace AppBundle\Tests\Security;


use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class RegisterEleveurTest extends WebTestCase
{

    public function testLoginForm()
    {
        $client = static::createClient();

        $registrationForm = $client->request('GET', '/register/')->filter('form')->form();

        // Création d'un nouvel utilisateur
        $registrationForm['fos_user_registration_form[username]'] = 'test';
        $registrationForm['fos_user_registration_form[email]'] = '<EMAIL>';
        $registrationForm['fos_user_registration_form[plainPassword][first]'] = '<PASSWORD>';
        $registrationForm['fos_user_registration_form[plainPassword][second]'] = '<PASSWORD>';

        // On doit arriver sur la page de confirmation
        $confirmation = $client->submit($registrationForm);
        $this->assertEquals(302, $client->getResponse()->getStatusCode());
        $this->assertEquals('/register/confirmed', $client->getResponse()->headers->get('Location'));

        // On est connecté sur ce nouvel utilisateur et on a le role ROLE_ELEVEUR
        $this->assertTrue($client->getContainer()->get('security.authorization_checker')->isGranted('ROLE_ELEVEUR'));
    }
}<commit_msg>Tests d'intégration stateless<commit_after><?php
/**
 * Created by PhpStorm.
 * User: apf
 * Date: 28/10/15
 * Time: 21:38
 */

namespace AppBundle\Tests\Security;


use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class RegisterEleveurTest extends WebTestCase
{

    public function testLoginForm()
    {
        $client = static::createClient();

        $registrationForm = $client->request('GET', '/register/')->filter('form')->form();

        // Création d'un nouvel utilisateur
        $registrationForm['fos_user_registration_form[username]'] = 'RegisterEleveurTest';
        $registrationForm['fos_user_registration_form[email]'] = '<EMAIL>';
        $registrationForm['fos_user_registration_form[plainPassword][first]'] = '<PASSWORD>';
        $registrationForm['fos_user_registration_form[plainPassword][second]'] = '<PASSWORD>';

        // On doit arriver sur la page de confirmation
        $confirmation = $client->submit($registrationForm);
        $this->assertEquals(302, $client->getResponse()->getStatusCode());
        $this->assertEquals('/register/confirmed', $client->getResponse()->headers->get('Location'));

        // On est connecté sur ce nouvel utilisateur et on a le role ROLE_ELEVEUR
        $this->assertTrue($client->getContainer()->get('security.authorization_checker')->isGranted('ROLE_ELEVEUR'));

        /**
         * @var \Doctrine\DBAL\Connection $conn
         */
        $conn = $client->getContainer()->get('database_connection');

        /**
         * @var \Doctrine\Bundle\DoctrineBundle\Registry $doctrine
         */
        $doctrine = $client->getContainer()->get('doctrine');

        $testUser = $doctrine->getRepository('AppBundle:User')->findOneBy(['username' => 'RegisterEleveurTest']);
        $doctrine->getManager()->remove($testUser);
        $doctrine->getManager()->flush();
    }
}
{'fraction_non_alphanumeric': 0.1571969696969697, 'fraction_numerical': 0.008207070707070708, 'mean_word_length': 3.890432098765432, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7584767', 'n_tokens_mistral': 947, 'n_tokens_neox': 890, 'n_words': 149}