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

WebTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A getEntityManager() 0 4 1
A getAuthClient() 0 17 1
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