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

UserControllerTest::testResetPassword()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 36
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 23
nc 1
nop 0
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