ResetPasswordActionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A tearDown() 0 5 1
A testSuccessPasswordReset() 0 23 1
1
<?php
2
/**
3
 * Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
4
 *
5
 * Licensed under The MIT License
6
 * Redistributions of files must retain the above copyright notice.
7
 *
8
 * @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
9
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
10
 */
11
12
namespace CakeDC\Api\Test\TestCase\Integration\Service\Action\Auth;
13
14
use CakeDC\Api\TestSuite\IntegrationTestCase;
15
use CakeDC\Api\Test\ConfigTrait;
16
use CakeDC\Api\Test\FixturesTrait;
17
use CakeDC\Api\Test\Settings;
18
use Cake\Core\Configure;
19
use Cake\ORM\TableRegistry;
20
21
/**
22
 * Class ResetPasswordActionTest
23
 *
24
 * @package CakeDC\Api\Test\TestCase\Integration\Service\Action\Auth
25
 */
26
class ResetPasswordActionTest extends IntegrationTestCase
27
{
28
29
    use ConfigTrait;
30
    use FixturesTrait;
31
32
    /**
33
     * setUp
34
     *
35
     * @return void
36
     */
37
    public function setUp()
38
    {
39
        parent::setUp();
40
        $this->_authAccess();
41
        Configure::write('App.fullBaseUrl', 'http://example.com');
42
    }
43
44
    /**
45
     * tearDown
46
     *
47
     * @return void
48
     */
49
    public function tearDown()
50
    {
51
        parent::tearDown();
52
        Configure::write('Test.Api.Extension', null);
53
    }
54
55
    public function testSuccessPasswordReset()
56
    {
57
        $this->sendRequest('/auth/reset_password_request', 'POST', ['reference' => 'user-1']);
58
        $result = $this->getJsonResponse();
59
        $this->assertSuccess($result);
60
        $this->assertTextEquals('Please check your email to continue with password reset process', $result['data']);
61
62
        $Users = TableRegistry::get('CakeDC/Users.Users');
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\TableRegistry::get() has been deprecated with message: 3.6.0 Use \Cake\ORM\Locator\TableLocator::get() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
63
        $user = $Users->find()->where(['id' => Settings::USER1])->enableHydration(false)->first();
64
65
        $this->sendRequest('/auth/reset_password', 'POST', [
66
            'token' => $user['token'],
67
            'password' => 'new-password',
68
            'password_confirm' => 'new-password',
69
        ]);
70
        $result = $this->getJsonResponse();
71
        $this->assertSuccess($result);
72
        $this->assertTextEquals('Password has been changed successfully', $result['data']);
73
74
        $this->sendRequest('/auth/login', 'POST', ['username' => 'user-1', 'password' => 'new-password']);
75
        $result = $this->getJsonResponse();
76
        $this->assertSuccess($result);
77
    }
78
}
79