Bugzilla – Attachment 170545 Details for
Bug 37513
Disable 'Delete' button if the record source cannot be deleted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37513: Add Koha::RecordSource->usage_count
Bug-37513-Add-KohaRecordSource-usagecount.patch (text/plain), 2.91 KB, created by
Matt Blenkinsop
on 2024-08-21 10:08:40 UTC
(
hide
)
Description:
Bug 37513: Add Koha::RecordSource->usage_count
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-08-21 10:08:40 UTC
Size:
2.91 KB
patch
obsolete
>From 4cb9882fa16e5db10da83b48f88dd700c19d4c35 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 19 Aug 2024 11:35:13 -0300 >Subject: [PATCH] Bug 37513: Add Koha::RecordSource->usage_count > >This patch adds the `usage_count` method to be used for embedding from >the API. Tests cover all use cases. > >To test: >1. Apply this patch >2. Run: > $ ktd --shell > k$ prove t/db_dependent/Koha/RecordSource.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >--- > Koha/RecordSource.pm | 15 ++++++++++ > t/db_dependent/Koha/RecordSource.t | 47 ++++++++++++++++++++++++++++++ > 2 files changed, 62 insertions(+) > create mode 100755 t/db_dependent/Koha/RecordSource.t > >diff --git a/Koha/RecordSource.pm b/Koha/RecordSource.pm >index 8b4fecbe25c..54f7921b6de 100644 >--- a/Koha/RecordSource.pm >+++ b/Koha/RecordSource.pm >@@ -31,6 +31,21 @@ Koha::RecordSource - Koha RecordSource Object class > > =head1 API > >+=head2 Class methods >+ >+=head3 usage_count >+ >+ my $count = $source->usage_count(); >+ >+This method returns the count for records using this record source. >+ >+=cut >+ >+sub usage_count { >+ my ($self) = @_; >+ return $self->_result->biblio_metadatas->count(); >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/t/db_dependent/Koha/RecordSource.t b/t/db_dependent/Koha/RecordSource.t >new file mode 100755 >index 00000000000..5a0bba3212f >--- /dev/null >+++ b/t/db_dependent/Koha/RecordSource.t >@@ -0,0 +1,47 @@ >+#!/usr/bin/perl >+ >+# 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 Test::More tests => 1; >+ >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'usage_count() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $source = $builder->build_object( { class => 'Koha::RecordSources' } ); >+ >+ is( $source->usage_count, 0, q{Unused record source has a count of 0} ); >+ >+ foreach ( 1 .. 3 ) { >+ my $biblio = $builder->build_sample_biblio(); >+ $biblio->metadata->record_source_id( $source->id )->store(); >+ } >+ >+ is( $source->usage_count, 3, q{3 records linked, count is 3} ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.39.3 (Apple Git-146)
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 37513
:
170475
|
170476
|
170477
|
170478
|
170479
|
170512
|
170513
|
170514
|
170515
|
170516
|
170544
| 170545 |
170546
|
170547
|
170548
|
171205
|
171236