Bugzilla – Attachment 120403 Details for
Bug 26273
Expose cashup summary history for a cash register
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28273: Unit tests
Bug-28273-Unit-tests.patch (text/plain), 3.91 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-05-03 12:59:44 UTC
(
hide
)
Description:
Bug 28273: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-05-03 12:59:44 UTC
Size:
3.91 KB
patch
obsolete
>From a71beaeb299b294939b4087d2bfe2f371f196c39 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 3 May 2021 09:45:25 -0300 >Subject: [PATCH] Bug 28273: Unit tests > >https://bugs.koha-community.org/show_bug.cgi?id=26273 >--- > t/db_dependent/Koha/Biblios.t | 83 ++++++++++++++++++++++++++++++++++- > 1 file changed, 82 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t >index 994bd9611bd..5758ea03e2f 100755 >--- a/t/db_dependent/Koha/Biblios.t >+++ b/t/db_dependent/Koha/Biblios.t >@@ -19,8 +19,11 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; >+ > use Test::Exception; >+use Test::MockModule; >+ > use MARC::Field; > > use C4::Items; >@@ -221,3 +224,81 @@ subtest 'custom_cover_image_url' => sub { > }; > > $schema->storage->txn_rollback; >+ >+subtest 'pickup_locations() tests' => sub { >+ >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ # Build 8 libraries >+ my $l_1 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1 } }); >+ my $l_2 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1 } }); >+ my $l_3 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1 } }); >+ my $l_4 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1 } }); >+ my $l_5 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1 } }); >+ my $l_6 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1 } }); >+ my $l_7 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1 } }); >+ my $l_8 = $builder->build_object({ class => 'Koha::Libraries', value => { pickup_location => 1 } }); >+ >+ # Mock Koha::Item->pickup_locations so we have control on the output >+ # The $switch variable controls the output. >+ my $switch = 0; >+ my $queries = [ >+ { branchcode => [ $l_1->branchcode, $l_2->branchcode ] }, >+ { branchcode => [ $l_3->branchcode, $l_4->branchcode ] }, >+ { branchcode => [ $l_5->branchcode, $l_6->branchcode ] }, >+ { branchcode => [ $l_7->branchcode, $l_8->branchcode ] } >+ ]; >+ >+ my $mock_item = Test::MockModule->new('Koha::Item'); >+ $mock_item->mock( >+ 'pickup_locations', >+ sub { >+ my $query = $queries->[$switch]; >+ $switch++; >+ return Koha::Libraries->search($query); >+ } >+ ); >+ >+ # Two biblios >+ my $biblio_1 = $builder->build_sample_biblio; >+ my $biblio_2 = $builder->build_sample_biblio; >+ >+ # Two items each >+ my $item_1_1 = $builder->build_sample_item({ biblionumber => $biblio_1->biblionumber }); >+ my $item_1_2 = $builder->build_sample_item({ biblionumber => $biblio_1->biblionumber }); >+ my $item_2_1 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber }); >+ my $item_2_2 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber }); >+ >+ my $biblios = Koha::Biblios->search( >+ { >+ biblionumber => [ $biblio_1->biblionumber, $biblio_2->biblionumber ] >+ } >+ ); >+ >+ my $library_ids = [ >+ Koha::Libraries->search( >+ { >+ branchcode => [ >+ $l_1->branchcode, $l_2->branchcode, $l_3->branchcode, >+ $l_4->branchcode, $l_5->branchcode, $l_6->branchcode, >+ $l_7->branchcode, $l_8->branchcode >+ ] >+ }, >+ { order_by => ['branchname'] } >+ )->_resultset->get_column('branchcode')->all >+ ]; >+ >+ my $pickup_locations_ids = [ >+ $biblios->pickup_locations->_resultset->get_column('branchcode')->all >+ ]; >+ >+ is_deeply( >+ $library_ids, >+ $pickup_locations_ids, >+ 'The addition of all biblios+items pickup locations is returned' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.31.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 26273
:
116176
|
116640
|
116685
|
116691
|
116692
|
116697
|
116698
|
116699
|
116710
|
116771
|
116772
|
116773
|
117449
|
117450
|
117451
|
117787
|
117793
|
117809
|
117810
|
117811
|
117829
|
117830
|
117831
|
117832
|
117833
|
117834
|
118125
|
118129
|
118130
|
118149
|
118150
|
118151
|
118152
|
120403
|
120404