ValidateAccountActionTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
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\Utility\Hash;
20
21
/**
22
 * Class ValidateAccountActionTest
23
 *
24
 * @package CakeDC\Api\Test\TestCase\Integration\Service\Action\Auth
25
 */
26
class ValidateAccountActionTest 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 testSuccessValidateAccount()
56
    {
57
        $this->sendRequest('/auth/login', 'POST', ['username' => 'user-6', 'password' => '12345']);
58
        $result = $this->getJsonResponse();
59
        $this->assertError($result, 401);
60
        $this->assertErrorMessage($result, 'User not found');
61
62
        $this->sendRequest('/auth/validate_account', 'POST', ['token' => 'token-6']);
63
        $result = $this->getJsonResponse();
64
        $this->assertSuccess($result);
65
        $this->assertEquals(__d('CakeDC/Api', 'User account validated successfully'), $result['data']);
66
67
        $this->sendRequest('/auth/login', 'POST', ['username' => 'user-6', 'password' => '12345']);
68
        $result = $this->getJsonResponse();
69
        $this->assertSuccess($result);
70
    }
71
}
72