2016-05-30 02:44:17 +03:00
|
|
|
<?php
|
2019-02-20 22:58:52 +03:00
|
|
|
namespace common\tests\unit\models;
|
2016-05-30 02:44:17 +03:00
|
|
|
|
|
|
|
use common\models\AccountSession;
|
2019-02-20 22:58:52 +03:00
|
|
|
use common\tests\unit\TestCase;
|
2016-05-30 02:44:17 +03:00
|
|
|
|
|
|
|
class AccountSessionTest extends TestCase {
|
|
|
|
|
|
|
|
public function testGenerateRefreshToken() {
|
2016-10-29 03:23:29 +03:00
|
|
|
$model = new AccountSession();
|
|
|
|
$model->generateRefreshToken();
|
|
|
|
$this->assertNotNull($model->refresh_token, 'method call will set refresh_token value');
|
2016-05-30 02:44:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetIp() {
|
2016-10-29 03:23:29 +03:00
|
|
|
$model = new AccountSession();
|
|
|
|
$model->setIp('127.0.0.1');
|
2019-02-26 02:26:02 +03:00
|
|
|
$this->assertSame(2130706433, $model->last_used_ip, 'method should convert passed ip string to long');
|
2016-05-30 02:44:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetReadableIp() {
|
2016-10-29 03:23:29 +03:00
|
|
|
$model = new AccountSession();
|
|
|
|
$model->last_used_ip = 2130706433;
|
2019-02-26 02:26:02 +03:00
|
|
|
$this->assertSame('127.0.0.1', $model->getReadableIp(), 'method should convert stored long into readable ip');
|
2016-05-30 02:44:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|