Bugzilla – Attachment 113669 Details for
Bug 26988
Defer loading the hold pickup locations until the dropdown is selected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26988: (QA follow-up) Unit tests
Bug-26988-QA-follow-up-Unit-tests.patch (text/plain), 4.32 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-11-16 16:14:42 UTC
(
hide
)
Description:
Bug 26988: (QA follow-up) Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-11-16 16:14:42 UTC
Size:
4.32 KB
patch
obsolete
>From 8a9e598e0091e28544331175ef80646d5aaca866 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 16 Nov 2020 12:54:13 -0300 >Subject: [PATCH] Bug 26988: (QA follow-up) Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/api/v1/holds.t | 108 +++++++++++++++++++++++++++++++++- > 1 file changed, 107 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index ff4f70ab1e8..585e19a8a50 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -17,7 +17,8 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 10; >+use Test::MockModule; > use Test::Mojo; > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -671,3 +672,108 @@ subtest 'add() tests (maxreserves behaviour)' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'pickup_locations() tests' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $library_1 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'A' } }); >+ my $library_2 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'B' } }); >+ my $library_3 = $builder->build_object({ class => 'Koha::Libraries', value => { marcorgcode => 'C' } }); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { userid => 'tomasito', flags => 1 } >+ } >+ ); >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $patron->userid; >+ >+ my $item_class = Test::MockModule->new('Koha::Item'); >+ $item_class->mock( >+ 'pickup_locations', >+ sub { >+ my ( $self, $params ) = @_; >+ my $mock_patron = $params->{patron}; >+ is( $mock_patron->borrowernumber, >+ $patron->borrowernumber, 'Patron passed correctly' ); >+ return Koha::Libraries->search( >+ { >+ branchcode => { >+ '-in' => [ >+ $library_1->branchcode, >+ $library_2->branchcode >+ ] >+ } >+ }, >+ { # we make sure no surprises in the order of the result >+ order_by => { '-asc' => 'marcorgcode' } >+ } >+ ); >+ } >+ ); >+ >+ my $biblio_class = Test::MockModule->new('Koha::Biblio'); >+ $biblio_class->mock( >+ 'pickup_locations', >+ sub { >+ my ( $self, $params ) = @_; >+ my $mock_patron = $params->{patron}; >+ is( $mock_patron->borrowernumber, >+ $patron->borrowernumber, 'Patron passed correctly' ); >+ return Koha::Libraries->search( >+ { >+ branchcode => { >+ '-in' => [ >+ $library_2->branchcode, >+ $library_3->branchcode >+ ] >+ } >+ }, >+ { # we make sure no surprises in the order of the result >+ order_by => { '-asc' => 'marcorgcode' } >+ } >+ ); >+ } >+ ); >+ >+ my $item = $builder->build_sample_item; >+ >+ # biblio-level hold >+ my $hold_1 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ itemnumber => undef, >+ biblionumber => $item->biblionumber, >+ borrowernumber => $patron->borrowernumber >+ } >+ } >+ ); >+ # item-level hold >+ my $hold_2 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ itemnumber => $item->itemnumber, >+ biblionumber => $item->biblionumber, >+ borrowernumber => $patron->borrowernumber >+ } >+ } >+ ); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/holds/" >+ . $hold_1->id >+ . "/pickup_locations" ) >+ ->json_is( [ $library_2->to_api, $library_3->to_api ] ); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/holds/" >+ . $hold_2->id >+ . "/pickup_locations" ) >+ ->json_is( [ $library_1->to_api, $library_2->to_api ] ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.29.2
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 26988
:
113395
|
113418
|
113426
|
113427
|
113428
|
113456
|
113457
|
113458
|
113459
|
113460
|
113502
|
113533
|
113534
|
113535
|
113536
|
113537
|
113538
|
113590
|
113601
| 113669