LoginActionTest::testLoginSuccess()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
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\LoginAction;
7
use yii2mod\user\tests\TestCase;
8
9
/**
10
 * Class LoginActionTest
11
 *
12
 * @package yii2mod\user\tests\actions
13
 */
14
class LoginActionTest extends TestCase
15
{
16
    /**
17
     * Runs the action.
18
     *
19
     * @param array $config
20
     *
21
     * @return string
22
     */
23
    protected function runAction(array $config = [])
24
    {
25
        $action = new LoginAction('login', $this->createController(), $config);
26
27
        return $action->run();
28
    }
29
30
    // Tests:
31
32
    public function testViewLogin()
33
    {
34
        $response = $this->runAction();
35
        $this->assertEquals('@vendor/yii2mod/yii2-user/views/login', $response['view']);
36
    }
37
38 View Code Duplication
    public function testLoginSuccess()
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
            'LoginForm' => [
42
                'email' => '[email protected]',
43
                'password' => 'password',
44
            ],
45
        ];
46
        $this->runAction();
47
        $this->assertFalse(Yii::$app->user->isGuest);
48
    }
49
50 View Code Duplication
    public function testLoginError()
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...
51
    {
52
        Yii::$app->request->bodyParams = [
53
            'LoginForm' => [
54
                'email' => '[email protected]',
55
                'password' => 'failed-password',
56
            ],
57
        ];
58
        $this->runAction();
59
        $this->assertTrue(Yii::$app->user->isGuest);
60
    }
61
}
62