DoctorKarma/t/00003-model-user.t

60 lines
1.4 KiB
Perl
Raw Normal View History

2022-02-07 21:35:28 +01:00
#!/usr/bin/env perl
use v5.30.0;
use strict;
use warnings;
use Test::Most tests => 7;
2022-02-07 21:35:28 +01:00
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.';
}
{
## GIVEN
my $expected_username = 'sergiotarxz';
my $expected_firstname = 'sergiotarxz';
my $expected_karma = 100;
my $expected_id_user = 100;
my $user = DoctorKarma::Model::User->new(
id_user => $expected_id_user,
username => $expected_username,
first_name => $expected_firstname,
karma => 0,
);
## WHEN
$user->karma($expected_karma);
## THEN
is $user->karma, $expected_karma, 'The karma is the actually expected after edition.';
}