Completed
Push — master ( b87dd6...1d32ac )
by Alexey
10:52
created

SignupFormTest::testCorrectSignup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
namespace frontend\tests\unit\models;
3
4
use common\fixtures\User as UserFixture;
5
use modules\users\models\SignupForm;
6
7
/**
8
 * Class SignupFormTest
9
 * @package frontend\tests\unit\models
10
 */
11
class SignupFormTest extends \Codeception\Test\Unit
12
{
13
    /**
14
     * @var \frontend\tests\UnitTester
15
     */
16
    protected $tester;
17
18
    /**
19
     * @inheritdoc
20
     */
21
    public function _before()
22
    {
23
        $this->tester->haveFixtures([
24
            'user' => [
25
                'class' => UserFixture::className(),
26
                'dataFile' => codecept_data_dir() . 'user.php'
27
            ]
28
        ]);
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function testCorrectSignup()
35
    {
36
        $model = new SignupForm([
37
            'username' => 'some_username',
38
            'email' => '[email protected]',
39
            'password' => 'some_password',
40
        ]);
41
42
        $user = $model->signup();
43
44
        expect($user)->isInstanceOf('modules\users\models\User');
45
46
        expect($user->username)->equals('some_username');
47
        expect($user->email)->equals('[email protected]');
48
        expect($user->validatePassword('some_password'))->true();
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function testNotCorrectSignup()
55
    {
56
        $model = new SignupForm([
57
            'username' => 'troy.becker',
58
            'email' => '[email protected]',
59
            'password' => 'some_password',
60
        ]);
61
62
        expect_not($model->signup());
63
        expect_that($model->getErrors('username'));
64
        expect_that($model->getErrors('email'));
65
    }
66
}
67