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 {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testGenerateRefreshToken(): void {
|
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
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testSetIp(): void {
|
2016-10-29 05:53:29 +05:30
|
|
|
$model = new AccountSession();
|
|
|
|
$model->setIp('127.0.0.1');
|
2019-02-26 04:56:02 +05:30
|
|
|
$this->assertSame(2130706433, $model->last_used_ip, 'method should convert passed ip string to long');
|
2016-05-30 05:14:17 +05:30
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testGetReadableIp(): void {
|
2016-10-29 05:53:29 +05:30
|
|
|
$model = new AccountSession();
|
|
|
|
$model->last_used_ip = 2130706433;
|
2019-02-26 04:56:02 +05:30
|
|
|
$this->assertSame('127.0.0.1', $model->getReadableIp(), 'method should convert stored long into readable ip');
|
2016-05-30 05:14:17 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|