use v5.30.0; use strict; use warnings; use Test::Most tests => 6; use Test::MockModule; use DBI; use Peace::Model::Application; BEGIN { use_ok 'Peace::Model::Developer'; } { ## GIVEN my $secret_bcrypt = 'hola'; my $name = 'Larry'; my $surname = 'Wall'; my $email = 'larry@perl.org'; my $country = 'US'; my $verified = 0; ## WHEN my $developer = Peace::Model::Developer->new( secret_bcrypt => $secret_bcrypt, name => $name, surname => $surname, email => $email, country => $country, verified => $verified, ); ## THEN ok $developer->isa('Peace::Model::Developer'), 'Instanced developer is made of Peace::Model::Developer.'; is $developer->secret_bcrypt, $secret_bcrypt, 'Secret is correctly setup'; is $developer->uuid, undef, 'Uuid is undef.'; } { ## GIVEN my $uuid = 'example'; my $secret_bcrypt = 'hola'; my $name = 'Larry'; my $surname = 'Wall'; my $email = 'larry@perl.org'; my $country = 'US'; my $verified = 0; my $developer = Peace::Model::Developer->new( secret_bcrypt => $secret_bcrypt, name => $name, surname => $surname, email => $email, country => $country, verified => $verified ); ## WHEN $developer->uuid($uuid); ## THEN is $developer->uuid, $uuid, 'Uuid can be set.'; } { ## GIVEN my $application_dao_mock = Test::MockModule->new('Peace::DAO::Application'); ### Developer data my $uuid = 'example'; my $secret_bcrypt = 'hola'; my $name = 'Larry'; my $surname = 'Wall'; my $email = 'larry@perl.org'; my $country = 'US'; my $verified = 0; my $dbh = DBI->connect( 'DBI:Mock:', '', '' ); ### Application data my $app_name0 = 'Desfronificator'; my $app_name1 = 'Desfronificator 1.0'; my $app_description = 'Desfronifies the files.'; my $app_url = 'https://desfronificator.example.com'; my $app_price = '4.20'; my $app_git_repo = 'https://git.desfronificator.example.com/larry/desfronificator.git'; my $app_flatpak_builder_file = './resources/com.example.desfronificator.yml'; my $app_verified = 0; my $developer = Peace::Model::Developer->new( secret_bcrypt => $secret_bcrypt, name => $name, surname => $surname, email => $email, country => $country, verified => $verified, dbh => $dbh, ); my $applications = [ Peace::Model::Application->new( name => $app_name0, description => $app_description, url => $app_url, price => $app_price, git_repo => $app_git_repo, flatpak_builder_file => $app_flatpak_builder_file, verified => $app_verified, developer => $developer, ), Peace::Model::Application->new( name => $app_name0, description => $app_description, url => $app_url, price => $app_price, git_repo => $app_git_repo, flatpak_builder_file => $app_flatpak_builder_file, verified => $app_verified, developer => $developer, ), ]; $application_dao_mock->mock( recover_by_developer => sub { return $applications; } ); ## WHEN my $new_applications = $developer->applications; ## THEN is_deeply $new_applications, $applications, 'Applications are correctly recovered from the developer.'; }