Bugzilla – Attachment 123047 Details for
Bug 20447
Add support for MARC holdings records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22690: (QA follow-up) Add TrackedLink classes and use them
Bug-22690-QA-follow-up-Add-TrackedLink-classes-and.patch (text/plain), 5.42 KB, created by
Joonas Kylmälä
on 2021-07-22 14:15:07 UTC
(
hide
)
Description:
Bug 22690: (QA follow-up) Add TrackedLink classes and use them
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2021-07-22 14:15:07 UTC
Size:
5.42 KB
patch
obsolete
>From b54be4122401ae759b7239fa30005c11b242826b Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 22 Jul 2021 11:40:20 +0100 >Subject: [PATCH] Bug 22690: (QA follow-up) Add TrackedLink classes and use > them > >This patch adds Koha::TrackedLink(s) classes based on Koha::Object(s) >and then adds the relationship accessor to Koha::Item and uses it within >the move_to_biblio method. > >Tests for new relationship also added to t/db_dependent/Koha/Item.t > >https://bugs.koha-community.org/show_bug.cgi?id=20447 >--- > Koha/Item.pm | 21 +++++++++++++--- > Koha/TrackedLink.pm | 43 +++++++++++++++++++++++++++++++++ > Koha/TrackedLinks.pm | 49 ++++++++++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Item.t | 18 +++++++++++++- > 4 files changed, 127 insertions(+), 4 deletions(-) > create mode 100644 Koha/TrackedLink.pm > create mode 100644 Koha/TrackedLinks.pm > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index b074d027fe..011f6276d7 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1189,6 +1189,21 @@ sub orders { > return Koha::Acquisition::Orders->_new_from_dbic($orders); > } > >+=head3 tracked_links >+ >+ my $tracked_links = $item->tracked_links(); >+ >+Returns a Koha::TrackedLinks object >+ >+=cut >+ >+sub tracked_links { >+ my ( $self ) = @_; >+ >+ my $tracked_links = $self->_result->linktrackers; >+ return Koha::TrackedLinks->_new_from_dbic($tracked_links); >+} >+ > =head3 move_to_biblio > > $item->move_to_biblio($to_biblio[, $params]); >@@ -1255,9 +1270,9 @@ sub move_to_biblio { > } > ); > >- # linktrackers (there's no Koha object set available yet) >- my $linktrackers = $self->_result->linktrackers; >- $linktrackers->update_all({ biblionumber => $to_biblionumber }); >+ # tracked_links >+ my $tracked_links = $self->tracked_links; >+ $tracked_links->update({ biblionumber => $to_biblionumber }); > > return $to_biblionumber; > } >diff --git a/Koha/TrackedLink.pm b/Koha/TrackedLink.pm >new file mode 100644 >index 0000000000..3f37bc746d >--- /dev/null >+++ b/Koha/TrackedLink.pm >@@ -0,0 +1,43 @@ >+package Koha::TrackedLink; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::TrackedLink - Koha TrackedLink Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'LinkTracker'; >+} >+ >+1; >diff --git a/Koha/TrackedLinks.pm b/Koha/TrackedLinks.pm >new file mode 100644 >index 0000000000..3ae1a6b585 >--- /dev/null >+++ b/Koha/TrackedLinks.pm >@@ -0,0 +1,49 @@ >+package Koha::TrackedLinks; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+ >+use Koha::Database; >+ >+use Koha::TrackedLink; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::TrackedLinks - Koha TrackedLink Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'LinkTracker'; >+} >+ >+sub object_class { >+ return 'Koha::TrackedLink'; >+} >+ >+1; >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index d03a60a30a..067cacd0f3 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 11; >+use Test::More tests => 12; > use Test::Exception; > > use C4::Biblio qw( GetMarcSubfieldStructure ); >@@ -38,6 +38,22 @@ use t::lib::Mocks; > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >+subtest 'tracked_links relationship' => sub { >+ plan tests => 3; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ }); >+ my $tracked_links = $item->tracked_links; >+ is( ref($tracked_links), 'Koha::TrackedLinks', 'tracked_links returns a Koha::TrackedLinks object set' ); >+ is($item->tracked_links->count, 0, "Empty Koha::TrackedLinks set returned if no tracked_links"); >+ my $link1 = $builder->build({ source => 'LinkTracker', value => { itemnumber => $item->itemnumber }}); >+ my $link2 = $builder->build({ source => 'LinkTracker', value => { itemnumber => $item->itemnumber }}); >+ >+ is($item->tracked_links()->count,2,"Two tracked links found"); >+}; >+ > subtest 'hidden_in_opac() tests' => sub { > > plan tests => 4; >-- >2.25.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 20447
:
73703
|
73704
|
76485
|
76542
|
76670
|
76671
|
76672
|
76735
|
76736
|
78178
|
78179
|
78180
|
78738
|
78739
|
78740
|
78907
|
79403
|
79413
|
79565
|
79566
|
79567
|
79568
|
79569
|
79570
|
79812
|
79813
|
79814
|
79815
|
79816
|
79819
|
80320
|
80321
|
80322
|
80323
|
80324
|
80823
|
80824
|
80825
|
80826
|
80827
|
81264
|
81265
|
81266
|
81267
|
81268
|
82669
|
82670
|
82671
|
82672
|
82673
|
83550
|
83551
|
83552
|
83553
|
83554
|
83555
|
83556
|
83557
|
83558
|
83559
|
85364
|
85368
|
85369
|
85370
|
85371
|
85416
|
85417
|
85418
|
85419
|
85906
|
85907
|
85908
|
85909
|
85994
|
85995
|
85996
|
85997
|
86088
|
86089
|
86090
|
86091
|
87307
|
87308
|
87309
|
87310
|
87346
|
87347
|
87348
|
87349
|
88751
|
88752
|
88753
|
88754
|
88755
|
91743
|
91744
|
91745
|
91746
|
91747
|
94539
|
94540
|
94541
|
94542
|
97796
|
97797
|
97798
|
97799
|
97800
|
97843
|
97844
|
97845
|
97846
|
99143
|
99144
|
99145
|
99146
|
99176
|
99177
|
99178
|
99179
|
99235
|
99236
|
99237
|
99238
|
99239
|
105068
|
105069
|
105070
|
105071
|
105072
|
105259
|
105260
|
105261
|
105262
|
105263
|
106147
|
106148
|
106149
|
106150
|
106151
|
108250
|
108251
|
108252
|
108253
|
108254
|
108255
|
108336
|
108337
|
108338
|
108339
|
108340
|
108341
|
108789
|
108790
|
108791
|
108792
|
108793
|
108794
|
109695
|
109696
|
109697
|
109698
|
109699
|
109700
|
109703
|
109704
|
109705
|
109706
|
109707
|
109708
|
109711
|
109712
|
109713
|
109714
|
109715
|
109717
|
109718
|
109719
|
109720
|
109721
|
109722
|
109741
|
109742
|
109743
|
109744
|
109745
|
109746
|
109765
|
109766
|
109767
|
109768
|
109769
|
109770
|
109873
|
109874
|
109875
|
109877
|
109878
|
109879
|
110115
|
110174
|
110313
|
110314
|
110315
|
110316
|
110317
|
110318
|
110319
|
110320
|
110467
|
110468
|
110469
|
110471
|
110472
|
110473
|
110474
|
110475
|
112176
|
112177
|
112179
|
112180
|
112181
|
112182
|
112189
|
112190
|
112191
|
112192
|
112193
|
112194
|
112570
|
112571
|
112572
|
112573
|
112574
|
112575
|
113943
|
113944
|
113945
|
113946
|
113947
|
113948
|
113952
|
113953
|
113954
|
113955
|
113956
|
113957
|
113958
|
113959
|
115239
|
115240
|
115241
|
115242
|
115243
|
115244
|
115245
|
115654
|
115655
|
115656
|
115657
|
115658
|
115659
|
115660
|
115722
|
115723
|
115724
|
115725
|
115726
|
115727
|
115728
|
115729
|
116797
|
116798
|
116799
|
116800
|
116801
|
116802
|
116803
|
116804
|
116805
|
116806
|
116807
|
116808
|
116809
|
116810
|
116811
|
116812
|
118382
|
118383
|
118385
|
118386
|
118387
|
118388
|
118389
|
118390
|
118397
|
118398
|
118399
|
118400
|
118401
|
118402
|
118403
|
118404
|
118405
|
118406
|
118407
|
118408
|
118409
|
118410
|
118411
|
118412
|
118429
|
118430
|
118431
|
118432
|
118433
|
118434
|
118435
|
118436
|
118527
|
118528
|
118529
|
118530
|
118531
|
118532
|
118533
|
118534
|
118535
|
118536
|
119265
|
119266
|
119267
|
119268
|
119269
|
119270
|
119271
|
119272
|
119273
|
119274
|
119514
|
119515
|
119516
|
119517
|
119518
|
119519
|
119520
|
119521
|
119522
|
119523
|
119570
|
119571
|
121216
|
121217
|
121220
|
121221
|
121222
|
121223
|
121226
|
121227
|
121228
|
121229
|
121230
|
121231
|
121379
|
121380
|
121381
|
121382
|
121383
|
121406
|
121407
|
121408
|
121409
|
121410
|
122501
|
122502
|
122503
|
122504
|
122505
|
122851
|
122852
|
122853
|
122854
|
122855
|
122856
|
122891
|
122892
|
122893
|
122894
|
122895
|
122896
|
122897
|
123047
|
123048
|
123049
|
123050
|
123051
|
123052
|
123053
|
123054
|
123055
|
123056
|
123057
|
123058
|
123059
|
123060
|
123061
|
124012
|
124013
|
124014
|
124015
|
124016
|
124017
|
124018
|
124944
|
124945
|
124946
|
124947
|
124948
|
124949
|
124950
|
126204
|
126205
|
126206
|
126207
|
126208
|
126209
|
126210
|
126211
|
126212
|
126296
|
126391
|
126392
|
126394
|
126395
|
126396
|
126397
|
126398
|
126399
|
126400
|
126401
|
126402
|
126403
|
126404
|
126405
|
126932
|
126933
|
126934
|
126935
|
126936
|
126937
|
126938
|
126939
|
126940
|
126941
|
126942
|
126943
|
127040
|
128079
|
128131
|
128134
|
130776
|
130777
|
130778
|
130779
|
130780
|
130781
|
130782
|
130783
|
130784
|
130785
|
130786
|
130787
|
130788
|
130789
|
130790
|
130791
|
130792
|
130793
|
130794
|
130795
|
130796
|
130797
|
130798
|
130799
|
130800
|
130801
|
130802
|
130803
|
130804
|
130805
|
130806
|
130807
|
131458
|
131459
|
131460
|
131461
|
131462
|
131463
|
131464
|
131465
|
131466
|
131467
|
131468
|
131469
|
131470
|
131471
|
131472
|
131473
|
131474
|
131475
|
131476
|
131477
|
131478
|
131479
|
131480
|
131481
|
131482
|
139865
|
139866
|
139867
|
139868
|
139869
|
139870
|
139871
|
139872
|
139873
|
139874
|
139875
|
139876
|
139877
|
139878
|
139879
|
139880
|
139881
|
139882
|
139883
|
139884
|
139885
|
139886
|
139887
|
139888
|
139889
|
139890
|
139891
|
139892
|
139893
|
139894
|
139895
|
139896
|
157492
|
157493