Bugzilla – Attachment 77013 Details for
Bug 18635
Koha::Patron->guarantees() should return results alphabetically
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18635 - Unit tests
Bug-18635---Unit-tests.patch (text/plain), 5.22 KB, created by
Nick Clemens (kidclamp)
on 2018-07-16 16:30:23 UTC
(
hide
)
Description:
Bug 18635 - Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-07-16 16:30:23 UTC
Size:
5.22 KB
patch
obsolete
>From b82f302e75d4a3fb35487d820495c5b25ee64260 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 18 May 2017 21:07:11 -0400 >Subject: [PATCH] Bug 18635 - Unit tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >I also adjust a few tests that assume value of $nb_of_patrons to not >rely on existing datas > >To test: >1 - Apply this patch only >2 - Prove t/db_dependent/Koha/Patrons.t >3 - Tests fail >4 - Apply other patch >5 - Tests pass > >Signed-off-by: Marc Véron <veron@veron.ch> >--- > t/db_dependent/Koha/Patrons.t | 58 +++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 53 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index bb6e2bc..4c83ee4 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -84,7 +84,7 @@ subtest 'library' => sub { > }; > > subtest 'guarantees' => sub { >- plan tests => 8; >+ plan tests => 13; > my $guarantees = $new_patron_1->guarantees; > is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' ); > is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee' ); >@@ -102,6 +102,53 @@ subtest 'guarantees' => sub { > is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' ); > is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' ); > $_->delete for @guarantees; >+ >+ #Test return order of guarantees BZ 18635 >+ my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; >+ my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; >+ >+ my $guarantor = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my $order_guarantee1 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Zebra', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $order_guarantee2 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Yak', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $order_guarantee3 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Xerus', >+ firstname => 'Walrus', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $order_guarantee4 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Xerus', >+ firstname => 'Vulture', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ my $order_guarantee5 = $builder->build_object( { class => 'Koha::Patrons' , value => { >+ surname => 'Xerus', >+ firstname => 'Unicorn', >+ guarantorid => $guarantor->borrowernumber >+ } >+ })->borrowernumber; >+ >+ $guarantees = $guarantor->guarantees(); >+ >+ is( $guarantees->next()->borrowernumber, $order_guarantee5, "Return first guarantor alphabetically" ); >+ is( $guarantees->next()->borrowernumber, $order_guarantee4, "Return second guarantor alphabetically" ); >+ is( $guarantees->next()->borrowernumber, $order_guarantee3, "Return third guarantor alphabetically" ); >+ is( $guarantees->next()->borrowernumber, $order_guarantee2, "Return fourth guarantor alphabetically" ); >+ is( $guarantees->next()->borrowernumber, $order_guarantee1, "Return fifth guarantor alphabetically" ); > }; > > subtest 'category' => sub { >@@ -997,6 +1044,7 @@ subtest 'libraries_where_can_see_patrons + can_see_patron_infos + search_limited > # + library_12 > # group2 > # + library21 >+ $nb_of_patrons = Koha::Patrons->search->count; > my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store; > my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store; > my $library_11 = $builder->build( { source => 'Branch' } ); >@@ -1067,8 +1115,8 @@ subtest 'libraries_where_can_see_patrons + can_see_patron_infos + search_limited > plan tests => 6; > > set_logged_in_user( $patron_11_1 ); >- my $total_number_of_patrons = $nb_of_patrons + 6; # 2 created before + 4 for these subtests >- is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons'); >+ my $total_number_of_patrons = $nb_of_patrons + 4; #we added four in these tests >+ is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons' ); > is( Koha::Patrons->search_limited->count, $total_number_of_patrons, 'patron_11_1 is allowed to see all patrons' ); > > set_logged_in_user( $patron_11_2 ); >@@ -1356,9 +1404,9 @@ subtest 'generate_userid' => sub { > $patron_2->delete; > }; > >- >+$nb_of_patrons = Koha::Patrons->search->count; > $retrieved_patron_1->delete; >-is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); >+is( Koha::Patrons->search->count, $nb_of_patrons - 1, 'Delete should have deleted the patron' ); > > subtest 'Log cardnumber change' => sub { > plan tests => 3; >-- >2.1.4
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 18635
:
63552
|
63553
|
63558
|
63559
|
63617
|
66557
|
66558
|
77005
|
77006
|
77011
|
77012
|
77013
|
77435
|
77436