Testing the user model.

This commit is contained in:
sergiotarxz 2022-02-07 21:35:28 +01:00
parent 06f832d8eb
commit 0132d56c96

38
t/00003-model-user.t Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env perl
use v5.30.0;
use strict;
use warnings;
use Test::Most tests => 6;
use Test::MockModule;
use Test::MockObject;
BEGIN {
unshift @INC, 'lib';
use_ok 'DoctorKarma::Model::User';
}
{
## GIVEN
my $expected_username = 'sergiotarxz';
my $expected_firstname = 'sergiotarxz';
my $expected_karma = 0;
my $expected_id_user = 100;
## WHEN
my $user = DoctorKarma::Model::User->new(
id_user => $expected_id_user,
username => $expected_username,
first_name => $expected_firstname,
karma => $expected_karma,
);
## THEN
ok $user->isa('DoctorKarma::Model::User'), 'User created succesfully.';
is $user->username, $expected_username, 'Username matchs.';
is $user->karma, $expected_karma, 'Karma matchs.';
is $user->first_name, $expected_firstname, 'Firstname matchs.';
is $user->id_user, $expected_id_user, 'Id_User matchs.';
}