SignupFormTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCorrectSignup() 0 16 1
A testNotCorrectSignup() 0 10 1
A fixtures() 0 9 1
1
<?php
2
3
namespace tests\codeception\frontend\unit\models;
4
5
use tests\codeception\frontend\unit\DbTestCase;
6
use tests\codeception\common\fixtures\UserFixture;
7
use Codeception\Specify;
8
use frontend\models\SignupForm;
9
10
class SignupFormTest extends DbTestCase
11
{
12
13
    use Specify;
14
15
    public function testCorrectSignup()
16
    {
17
        $model = new SignupForm([
18
            'username' => 'some_username',
19
            'email' => '[email protected]',
20
            'password' => 'some_password',
21
        ]);
22
23
        $user = $model->signup();
24
25
        $this->assertInstanceOf('common\models\User', $user, 'user should be valid');
26
27
        expect('username should be correct', $user->username)->equals('some_username');
28
        expect('email should be correct', $user->email)->equals('[email protected]');
29
        expect('password should be correct', $user->validatePassword('some_password'))->true();
30
    }
31
32
    public function testNotCorrectSignup()
33
    {
34
        $model = new SignupForm([
35
            'username' => 'troy.becker',
36
            'email' => '[email protected]',
37
            'password' => 'some_password',
38
        ]);
39
40
        expect('username and email are in use, user should not be created', $model->signup())->null();
41
    }
42
43
    public function fixtures()
44
    {
45
        return [
46
            'user' => [
47
                'class' => UserFixture::className(),
48
                'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php',
49
            ],
50
        ];
51
    }
52
53
}
54