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