2022-02-07 21:35:28 +01:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use v5.30.0;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2022-02-07 23:57:09 +01:00
|
|
|
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.';
|
|
|
|
}
|
2022-02-07 23:57:09 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
## 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.';
|
|
|
|
}
|