Bugzilla – Attachment 53340 Details for
Bug 16911
Koha::Patrons - Move ExtendMemberSubscriptionTo to ->renew_account
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16911: Koha::Patrons - Add tests for ->extend_subscription
Bug-16911-KohaPatrons---Add-tests-for--extendsubsc.patch (text/plain), 3.42 KB, created by
Jonathan Druart
on 2016-07-12 18:56:20 UTC
(
hide
)
Description:
Bug 16911: Koha::Patrons - Add tests for ->extend_subscription
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-07-12 18:56:20 UTC
Size:
3.42 KB
patch
obsolete
>From c3a1a0757393f2d917da033612a9e9935fcbba36 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 12 Jul 2016 00:18:56 +0100 >Subject: [PATCH] Bug 16911: Koha::Patrons - Add tests for > ->extend_subscription > >--- > t/db_dependent/Koha/Patrons.t | 51 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 50 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index fafd829..644f22e 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,13 +19,18 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; >+ >+use C4::Members; > > use Koha::Patron; > use Koha::Patrons; > use Koha::Database; >+use Koha::DateUtils; >+use Koha::Virtualshelves; > > use t::lib::TestBuilder; >+use t::lib::Mocks; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -98,6 +103,50 @@ subtest 'siblings' => sub { > $retrieved_guarantee_1->delete; > }; > >+subtest 'extend_subscription' => sub { >+ plan tests => 6; >+ my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); >+ my $a_year_later = dt_from_string->add( months => 12 )->truncate( to => 'day' ); >+ my $a_year_later_minus_a_month = dt_from_string->add( months => 11 )->truncate( to => 'day' ); >+ my $patron_category = $builder->build( >+ { source => 'Category', >+ value => { >+ enrolmentperiod => 12, >+ enrolmentperioddate => undef, >+ } >+ } >+ ); >+ my $patron = $builder->build( >+ { source => 'Borrower', >+ value => { >+ dateexpiry => $a_month_ago, >+ categorycode => $patron_category->{categorycode}, >+ } >+ } >+ ); >+ my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ >+ t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' ); >+ t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); >+ my $expiry_date = $retrieved_patron->extend_subscription; >+ is( $expiry_date, $a_year_later_minus_a_month, ); >+ my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry; >+ is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month ); >+ my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; >+ is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->extend_subscription should have logged' ); >+ >+ t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' ); >+ t::lib::Mocks::mock_preference( 'BorrowersLog', 0 ); >+ $expiry_date = $retrieved_patron->extend_subscription; >+ is( $expiry_date, $a_year_later, ); >+ $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry; >+ is( dt_from_string($retrieved_expiry_date), $a_year_later ); >+ $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; >+ is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->extend_subscription should not have logged' ); >+ >+ $retrieved_patron->delete; >+}; >+ > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); > >-- >2.8.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 16911
:
53338
|
53339
|
53340
|
53341
|
53346
|
53514
|
53515
|
53516
|
53517
|
53518
|
53533
|
54752
|
54753
|
54754
|
54755
|
54756
|
54757
|
54789
|
54790
|
54791
|
54792
|
54793
|
54794
|
55191
|
55192
|
55193
|
55194
|
55195
|
55196
|
55197
|
55424
|
55447