1
0
mirror of https://github.com/Bubka/2FAuth.git synced 2025-08-16 08:37:53 +02:00
Files
.github
app
bootstrap
config
database
docker
docs
public
resources
routes
storage
tests
Api
Classes
Data
EndToEnd
Feature
Unit
Api
Events
Exceptions
Listeners
GroupModelTest.php
HelpersTest.php
MigratorTest.php
TwoFAccountModelTest.php
UserModelTest.php
CreatesApplication.php
FeatureTestCase.php
ModelTestCase.php
TestCase.php
.dockerignore
.editorconfig
.env.example
.env.testing
.env.travis
.gitattributes
.gitignore
.styleci.yml
.travis.yml
Dockerfile
LICENSE
Procfile
README.md
_ide_helper.php
_ide_helper_models.php
app.json
artisan
changelog.md
composer.json
composer.lock
crowdin.yml
jsconfig.json
nginx.conf
package-lock.json
package.json
phpstan.neon
phpunit-mysql.xml
phpunit.xml
pint.json
vite.config.js
webpack.mix.js
2FAuth/tests/Unit/UserModelTest.php
2023-08-01 16:33:55 +02:00

70 lines
1.6 KiB
PHP

<?php
namespace Tests\Unit;
use App\Models\Group;
use App\Models\TwoFAccount;
use App\Models\User;
use PHPUnit\Framework\Attributes\CoversClass;
use Tests\ModelTestCase;
/**
* UserModelTest test class
*/
#[CoversClass(User::class)]
class UserModelTest extends ModelTestCase
{
/**
* @test
*/
public function test_model_configuration()
{
$this->runConfigurationAssertions(new User(),
['name', 'email', 'password'],
['password', 'remember_token'],
['*'],
[],
[
'id' => 'int',
'email_verified_at' => 'datetime',
'password' => 'hashed',
'is_admin' => 'boolean',
'twofaccounts_count' => 'integer',
'groups_count' => 'integer',
]
);
}
/**
* @test
*/
public function test_email_is_set_lowercased()
{
$user = User::factory()->make([
'email' => 'UPPERCASE@example.COM',
]);
$this->assertEquals(strtolower('UPPERCASE@example.COM'), $user->email);
}
/**
* @test
*/
public function test_twofaccounts_relation()
{
$user = new User();
$accounts = $user->twofaccounts();
$this->assertHasManyRelation($accounts, $user, new TwoFAccount());
}
/**
* @test
*/
public function test_groups_relation()
{
$user = new User();
$groups = $user->groups();
$this->assertHasManyRelation($groups, $user, new Group());
}
}