Bug 31095: Remove keyed_on_code
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 24 Aug 2022 15:20:05 +0000 (16:20 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 31 Jan 2023 13:19:37 +0000 (10:19 -0300)
We no longer require keyed_on_code from Koha::Patron::Restrictoin::Types
as we have relation accessors for the relevent use cases and no longer
reference the method anywhere in the codebase!

Test plan
1. Confirm 'keyed_on_code' is no longer referenced anywhere in the
   codebase.
   `git grep keyed_on_code`

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Patron/Restriction/Types.pm
t/db_dependent/Koha/Patron/Restriction/Types.t [deleted file]

index 7f7911c..2c1b37e 100644 (file)
@@ -32,24 +32,6 @@ Koha::Patron::Restriction::Types - Koha Restriction Types Object set class
 
 =cut
 
-=head3 keyed_on_code
-
-Return all restriction types as a hashref keyed on the code
-
-=cut
-
-sub keyed_on_code {
-    my ( $self ) = @_;
-
-    my @all = $self->_resultset()->search();
-    my $out = {};
-    for my $r( @all ) {
-        my %col = $r->get_columns;
-        $out->{$r->code} = \%col;
-    }
-    return $out;
-}
-
 =head3 _type
 
 =cut
diff --git a/t/db_dependent/Koha/Patron/Restriction/Types.t b/t/db_dependent/Koha/Patron/Restriction/Types.t
deleted file mode 100755 (executable)
index fb11089..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/perl
-
-use Modern::Perl;
-
-use C4::Context;
-use Koha::Database;
-use t::lib::TestBuilder;
-
-use Test::More tests => 2;
-
-my $schema = Koha::Database->new->schema;
-$schema->storage->txn_begin;
-my $dbh     = C4::Context->dbh;
-my $builder = t::lib::TestBuilder->new;
-
-use_ok('Koha::Patron::Restriction::Types');
-
-$dbh->do(q|DELETE FROM borrower_debarments|);
-$dbh->do(q|DELETE FROM restriction_types|);
-
-$builder->build(
-    {
-        source => 'RestrictionType',
-        value  => {
-            code         => 'ONE',
-            display_text => 'One',
-            is_system    => 1,
-            is_default   => 0
-        }
-    }
-);
-$builder->build(
-    {
-        source => 'RestrictionType',
-        value  => {
-            code         => 'TWO',
-            display_text => 'Two',
-            is_system    => 1,
-            is_default   => 1
-        }
-    }
-);
-
-# keyed_on_code
-my $keyed     = Koha::Patron::Restriction::Types->keyed_on_code;
-my $expecting = {
-    ONE => {
-        code         => 'ONE',
-        display_text => 'One',
-        is_system    => 1,
-        is_default   => 0
-    },
-    TWO => {
-        code         => 'TWO',
-        display_text => 'Two',
-        is_system    => 1,
-        is_default   => 1
-    }
-};
-
-is_deeply( $keyed, $expecting, 'keyed_on_code returns correctly' );
-
-$schema->storage->txn_rollback;