SignupActionTest::testViewSignup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace yii2mod\user\tests\actions;
4
5
use Yii;
6
use yii2mod\user\actions\SignupAction;
7
use yii2mod\user\tests\TestCase;
8
9
/**
10
 * Class SignupActionTest
11
 *
12
 * @package yii2mod\user\tests\actions
13
 */
14
class SignupActionTest extends TestCase
15
{
16
    /**
17
     * Runs the action.
18
     *
19
     * @param array $config
20
     *
21
     * @return array|\yii\web\Response response
22
     */
23
    protected function runAction(array $config = [])
24
    {
25
        $action = new SignupAction('signup', $this->createController(), $config);
26
27
        return $action->run();
28
    }
29
30
    // Tests:
31
32
    public function testViewSignup()
33
    {
34
        $response = $this->runAction();
35
        $this->assertEquals('@vendor/yii2mod/yii2-user/views/signup', $response['view']);
36
    }
37
38 View Code Duplication
    public function testSignupSuccess()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        Yii::$app->request->bodyParams = [
41
            'SignupForm' => [
42
                'email' => '[email protected]',
43
                'password' => 'password',
44
                'username' => 'test-user',
45
            ],
46
        ];
47
        $this->runAction();
48
        $this->assertFalse(Yii::$app->user->isGuest);
49
    }
50
51
    public function testSignupError()
52
    {
53
        Yii::$app->request->bodyParams = [
54
            'SignupForm' => [
55
                'email' => '[email protected]',
56
                'password' => 'failed-password',
57
            ],
58
        ];
59
        $response = $this->runAction();
60
        $this->assertFalse($response['params']['model']->validate());
61
    }
62
}
63