Bugzilla – Attachment 117800 Details for
Bug 27851
Add Koha::Old::Checkouts->filter_by_todays_checkins method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27851: Add tests
Bug-27851-Add-tests.patch (text/plain), 3.02 KB, created by
Jonathan Druart
on 2021-03-05 10:47:07 UTC
(
hide
)
Description:
Bug 27851: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-05 10:47:07 UTC
Size:
3.02 KB
patch
obsolete
>From 0dc234848fd77cdf1e9f29a0caaebe0bd04ab19e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 5 Mar 2021 11:43:21 +0100 >Subject: [PATCH] Bug 27851: Add tests > >--- > t/db_dependent/Koha/Checkouts.t | 67 ++++++++++++++++++++++++++++++++- > 1 file changed, 66 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Checkouts.t b/t/db_dependent/Koha/Checkouts.t >index 60722ce0ba..87d73fecc5 100755 >--- a/t/db_dependent/Koha/Checkouts.t >+++ b/t/db_dependent/Koha/Checkouts.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 8; >+use Test::More tests => 9; > > use C4::Circulation; > use Koha::Checkouts; >@@ -27,6 +27,7 @@ use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > > use t::lib::TestBuilder; >+use t::lib::Mocks; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -155,5 +156,69 @@ subtest 'issuer' => sub { > > }; > >+subtest 'Koha::Old::Checkouts->filter_by_todays_checkins' => sub { >+ >+ plan tests => 3; >+ >+ # We will create 7 checkins for a given patron >+ # 3 checked in today - 2 days, and 4 checked in today >+ my $librarian = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->{branchcode} } >+ } >+ ); >+ t::lib::Mocks::mock_userenv( { patron => $librarian } ); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->{branchcode} } >+ } >+ ); >+ >+ my @checkouts; >+ # Create 7 checkouts >+ for ( 0 .. 6 ) { >+ my $item = $builder->build_sample_item; >+ push @checkouts, >+ Koha::Checkout->new( >+ { >+ borrowernumber => $patron->borrowernumber, >+ itemnumber => $item->itemnumber, >+ branchcode => $library->{branchcode}, >+ } >+ )->store; >+ } >+ >+ # Checkin 3 today - 2 days >+ my $not_today = dt_from_string->add( days => -2 ); >+ for my $i ( 0 .. 2 ) { >+ my $checkout = $checkouts[$i]; >+ C4::Circulation::AddReturn( >+ $checkout->item->barcode, $library->{branchcode}, >+ undef, $not_today->set_hour( int( rand(24) ) ) >+ ); >+ } >+ # Checkin 4 today >+ my $today = dt_from_string; >+ for my $i ( 3 .. 6 ) { >+ my $checkout = $checkouts[$i]; >+ C4::Circulation::AddReturn( >+ $checkout->item->barcode, $library->{branchcode}, >+ undef, $today->set_hour( int( rand(24) ) ) >+ ); >+ } >+ >+ my $old_checkouts = $patron->old_checkouts; >+ is( $old_checkouts->count, 7, 'There should be 7 old checkouts' ); >+ my $todays_checkins = $old_checkouts->filter_by_todays_checkins; >+ is( $todays_checkins->count, 4, 'There should be 4 checkins today' ); >+ is_deeply( >+ [ $todays_checkins->get_column('itemnumber') ], >+ [ map { $_->itemnumber } @checkouts[ 3 .. 6 ] ], >+ q{Correct list of today's checkins} >+ ); >+}; >+ > $schema->storage->txn_rollback; > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27851
:
117800
|
117801
|
117802
|
117803
|
117822
|
117823
|
117824
|
117825
|
117826
|
117827
|
117828
|
117836
|
117837
|
117838
|
117839