Completed
Push — master ( 8f16eb...0002ba )
by Guillaume
04:27
created

WebTest::getAuthClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace Starkerxp\StructureBundle\Tests;
4
5
use Liip\FunctionalTestBundle\Test\WebTestCase;
6
use Starkerxp\UtilisateurBundle\Entity\Utilisateur;
7
8
abstract class WebTest extends WebTestCase
9
{
10
    protected $identifiant = "[email protected]";
11
    protected $motDePasse = "motMotDePasse";
12
13
    /**
14
     * Erase all database data.
15
     */
16
    public function setUp()
17
    {
18
        $this->loadFixtureFiles([]);
19
    }
20
21
    /**
22
     * Retourne l'entity manager de la connexion defaut.
23
     *
24
     * @return \Doctrine\Common\Persistence\ObjectManager|object
25
     */
26
    protected function getEntityManager()
27
    {
28
        return $this->getContainer()->get('doctrine')->getManager();
29
    }
30
31
    protected function getAuthClient()
32
    {
33
        $client = static::createClient();
34
        $client->request(
35
            'POST',
36
            '/api/login_check',
37
            [
38
                'identifiant' => $this->identifiant,
39
                'motDePasse'  => $this->motDePasse,
40
            ]
41
        );
42
        $dataHeader = json_decode($client->getResponse()->getContent(), true);
43
44
        $client = static::createClient();
45
        $client->setServerParameter('HTTP_Authorization', sprintf('Bearer %s', $dataHeader['token']));
46
        return $client;
47
    }
48
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
49