From 12159698265e71178c1ec97e613f8dc989bd653f Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 28 Apr 2022 17:54:11 +0000 Subject: [PATCH] Bug 30553: Unit tests --- t/db_dependent/Koha/Patron.t | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index 6418d6066f..a4a26f76b2 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 16; +use Test::More tests => 17; use Test::Exception; use Test::Warn; @@ -29,6 +29,7 @@ use Koha::DateUtils qw(dt_from_string); use Koha::ArticleRequests; use Koha::Patrons; use Koha::Patron::Relationships; +use Koha::Patron::Files; use t::lib::TestBuilder; use t::lib::Mocks; @@ -1137,3 +1138,26 @@ subtest 'recalls() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'filecount() tests' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + t::lib::Mocks::mock_preference( 'EnableBorrowerFiles', 1 ); + + my $patron_1 = $builder->build_object({ class => 'Koha::Patrons' }); + + is($patron_1->filecount, 0 , "Patron has 0 files"); + + my $bf = Koha::Patron::Files->new( borrowernumber => $patron_1->id ); + $bf->AddFile( name => 'name1', type => 'type1', + description => '', content => 'content1' ); + is($patron_1->filecount, 1 , "Patron has 1 files"); + $bf->AddFile( name => 'name2', type => 'type2', + description => '', content => 'content2' ); + is($patron_1->filecount, 2 , "Patron has many files"); + + $schema->storage->txn_rollback; +}; -- 2.30.2