yii2-netdisk/tests/unit/models/UserTest.php
Luke English 9d3b84517a
Update composer depedencies to be the same as the advanced application (#262)
* Compatible with PHP 8.1 and Codeception 5
* Add PHP 8.1 to workflow
* PHP 7.4 as a minimum
* Updated dependencies

Co-authored-by: Luke English <luke.english@ec2i.biz>
2022-06-17 19:15:52 +03:00

45 lines
1.2 KiB
PHP

<?php
namespace tests\unit\models;
use app\models\User;
class UserTest extends \Codeception\Test\Unit
{
public function testFindUserById()
{
verify($user = User::findIdentity(100))->notEmpty();
verify($user->username)->equals('admin');
verify(User::findIdentity(999))->empty();
}
public function testFindUserByAccessToken()
{
verify($user = User::findIdentityByAccessToken('100-token'))->notEmpty();
verify($user->username)->equals('admin');
verify(User::findIdentityByAccessToken('non-existing'))->empty();
}
public function testFindUserByUsername()
{
verify($user = User::findByUsername('admin'))->notEmpty();
verify(User::findByUsername('not-admin'))->empty();
}
/**
* @depends testFindUserByUsername
*/
public function testValidateUser()
{
$user = User::findByUsername('admin');
verify($user->validateAuthKey('test100key'))->notEmpty();
verify($user->validateAuthKey('test102key'))->empty();
verify($user->validatePassword('admin'))->notEmpty();
verify($user->validatePassword('123456'))->empty();
}
}