Completed
Pull Request — master (#30)
by nonanerz
07:53
created

UserControllerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testResetPassword() 0 36 1
1
<?php
2
3
namespace Tests\AppBundle\Controller\Api;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
class UserControllerTest extends WebTestCase
8
{
9
    public function testResetPassword()
10
    {
11
        exec('./bin/console d:d:c --env=test');
12
        exec('./bin/console d:s:c --env=test');
13
        exec('./bin/console h:f:l -n --env=test');
14
15
        $client = static::createClient();
16
        $content = '{"email":"1"}';
17
        $client->request(
18
            'POST',
19
            '/api/password_reset',
20
            array(),
21
            array(),
22
            array('CONTENT_TYPE' => 'application/json'),
23
            $content
24
25
        );
26
27
        $this->assertEquals(404, $client->getResponse()->getStatusCode());
28
29
        $json = '{            
30
                "email": "[email protected]"          
31
        }';
32
33
        $client->request('POST', '/api/password_reset', [], [], ['CONTENT_TYPE' => 'application/json'], $json
34
        );
35
        $this->assertTrue(
36
            $client->getResponse()->headers->contains(
37
                'Content-Type',
38
                'application/json'
39
            ),
40
            'the "Content-Type" header is "application/json"'
41
        );
42
        $this->assertTrue($client->getResponse()->isSuccessful(), 'response status is 2xx');
43
        exec('./bin/console d:d:d --force --env=test');
44
    }
45
}
46