Рефакторинг common unit тестов

This commit is contained in:
ErickSkrauch
2016-10-29 03:23:29 +03:00
parent 0e7013d9f5
commit d0548872f1
12 changed files with 88 additions and 103 deletions

View File

@@ -1,35 +1,27 @@
<?php
namespace codeception\common\unit\models;
use Codeception\Specify;
use common\models\AccountSession;
use tests\codeception\common\unit\TestCase;
class AccountSessionTest extends TestCase {
use Specify;
public function testGenerateRefreshToken() {
$this->specify('method call will set refresh_token value', function() {
$model = new AccountSession();
$model->generateRefreshToken();
expect($model->refresh_token)->notNull();
});
$model = new AccountSession();
$model->generateRefreshToken();
$this->assertNotNull($model->refresh_token, 'method call will set refresh_token value');
}
public function testSetIp() {
$this->specify('method should convert passed ip string to long', function() {
$model = new AccountSession();
$model->setIp('127.0.0.1');
expect($model->last_used_ip)->equals(2130706433);
});
$model = new AccountSession();
$model->setIp('127.0.0.1');
$this->assertEquals(2130706433, $model->last_used_ip, 'method should convert passed ip string to long');
}
public function testGetReadableIp() {
$this->specify('method should convert stored ip long into readable ip string', function() {
$model = new AccountSession();
$model->last_used_ip = 2130706433;
expect($model->getReadableIp())->equals('127.0.0.1');
});
$model = new AccountSession();
$model->last_used_ip = 2130706433;
$this->assertEquals('127.0.0.1', $model->getReadableIp(), 'method should convert stored long into readable ip');
}
}