Bugzilla – Attachment 105437 Details for
Bug 23820
Club hold pickup locations should be able to default to patron's home library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23820: Add test for new behaviour
Bug-23820-Add-test-for-new-behaviour.patch (text/plain), 6.71 KB, created by
Agustín Moyano
on 2020-05-29 16:26:00 UTC
(
hide
)
Description:
Bug 23820: Add test for new behaviour
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2020-05-29 16:26:00 UTC
Size:
6.71 KB
patch
obsolete
>From dc4d7808322db312414d3dc7d17ed7ec1cd3d9ea Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Fri, 29 May 2020 13:16:29 -0300 >Subject: [PATCH] Bug 23820: Add test for new behaviour > >To test: >1. prove t/db_dependent/api/v1/clubs_holds.t >2. Sign off > >Sponsored-by: Southeast Kansas Library - SEKLS >--- > t/db_dependent/api/v1/clubs_holds.t | 67 +++++++++++++++++++++++++---- > 1 file changed, 59 insertions(+), 8 deletions(-) > >diff --git a/t/db_dependent/api/v1/clubs_holds.t b/t/db_dependent/api/v1/clubs_holds.t >index 352e2f1190..240018f65f 100644 >--- a/t/db_dependent/api/v1/clubs_holds.t >+++ b/t/db_dependent/api/v1/clubs_holds.t >@@ -18,7 +18,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > use Test::Mojo; > use Test::Warn; > >@@ -26,10 +26,15 @@ use t::lib::TestBuilder; > use t::lib::Mocks; > > use C4::Auth; >+use C4::Context; > use Koha::Database; >+use Koha::Holds; >+use Koha::Patrons; >+use JSON qw( decode_json ); > > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; >+my $dbh = C4::Context->dbh; > > # FIXME: sessionStorage defaults to mysql, but it seems to break transaction handling > # this affects the other REST api tests >@@ -82,6 +87,39 @@ subtest 'add() tests' => sub { > }; > }; > >+subtest "default patron home" => sub { >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ my ($club_with_enrollments, $club_without_enrollments, $item, @enrollments) = create_test_data(); >+ >+ my ( undef, $session_id ) = create_user_and_session({ authorized => 1 }); >+ my $data = { >+ biblio_id => $item->biblionumber, >+ pickup_library_id => $item->home_branch->branchcode, >+ default_patron_home => 1 >+ }; >+ >+ my $tx = $t->ua->build_tx(POST => "/api/v1/clubs/".$club_with_enrollments->id."/holds" => json => $data); >+ $tx->req->cookies({ name => 'CGISESSID', value => $session_id }); >+ $t->request_ok($tx) >+ ->status_is(201, 'Created Hold'); >+ >+ my $json_response = decode_json $t->tx->res->content->get_body_chunk; >+ >+ my $sth = $dbh->prepare( >+ "select patron_id, hold_id from club_holds_to_patron_holds where club_hold_id = ?" >+ ); >+ $sth->execute($json_response->{club_hold_id}); >+ while (my $test = $sth->fetchrow_hashref()) { >+ my $hold = Koha::Holds->find($test->{hold_id}); >+ my $patron = Koha::Patrons->find($test->{patron_id}); >+ is($hold->branchcode, $patron->branchcode, 'Pickup location should be patrons home branch'); >+ } >+ $schema->storage->txn_rollback; >+}; >+ > sub unauthorized_access_tests { > my ($verb, $endpoint, $club_hold_id, $json) = @_; > >@@ -138,12 +176,25 @@ sub create_user_and_session { > sub create_test_data { > my $club_with_enrollments = $builder->build_object( { class => 'Koha::Clubs' } ); > my $club_without_enrollments = $builder->build_object( { class => 'Koha::Clubs' } ); >- my $enrollment1 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef } } ); >- my $enrollment2 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef } } ); >- my $enrollment3 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef } } ); >- my $enrollment4 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef } } ); >- my $enrollment5 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef } } ); >- my $enrollment6 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef } } ); >- my $item = $builder->build_sample_item(); >+ my $lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => {branchcode => $lib->branchcode}}); >+ my $enrollment1 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef, borrowernumber => $patron->borrowernumber } } ); >+ $lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); >+ $patron = $builder->build_object({ class => 'Koha::Patrons', value => {branchcode => $lib->branchcode}}); >+ my $enrollment2 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef, borrowernumber => $patron->borrowernumber } } ); >+ $lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); >+ $patron = $builder->build_object({ class => 'Koha::Patrons', value => {branchcode => $lib->branchcode}}); >+ my $enrollment3 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef, borrowernumber => $patron->borrowernumber } } ); >+ $lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); >+ $patron = $builder->build_object({ class => 'Koha::Patrons', value => {branchcode => $lib->branchcode}}); >+ my $enrollment4 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef, borrowernumber => $patron->borrowernumber } } ); >+ $lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); >+ $patron = $builder->build_object({ class => 'Koha::Patrons', value => {branchcode => $lib->branchcode}}); >+ my $enrollment5 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef, borrowernumber => $patron->borrowernumber } } ); >+ $lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); >+ $patron = $builder->build_object({ class => 'Koha::Patrons', value => {branchcode => $lib->branchcode}}); >+ my $enrollment6 = $builder->build_object( { class => 'Koha::Club::Enrollments', value => { club_id => $club_with_enrollments->id, date_canceled => undef, borrowernumber => $patron->borrowernumber } } ); >+ $lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); >+ my $item = $builder->build_sample_item({homebranch => $lib->branchcode}); > return ( $club_with_enrollments, $club_without_enrollments, $item, [ $enrollment1, $enrollment2, $enrollment3, $enrollment4, $enrollment5, $enrollment6 ] ); > } >\ No newline at end of file >-- >2.25.0
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 23820
:
102093
|
102153
|
105437
|
106561
|
106562
|
106563
|
107128