Browse Source

Bug 23321: Koha::Library additions

This patch adds the relationship accessor for Cash::Registers to the
Koha::Library class and include the relevant tests.

Sponsored-by: PTFS Europe
Sponsored-by: Cheshire Libraries Shared Services

Signed-off-by: Maryse Simard <maryse.simard@inlibro.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
remotes/origin/19.11.x
Martin Renvoize 5 years ago
parent
commit
0b72c3c068
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 12
      Koha/Library.pm
  2. 37
      t/db_dependent/Koha/Libraries.t

12
Koha/Library.pm

@ -77,6 +77,18 @@ sub library_groups {
return Koha::Library::Groups->_new_from_dbic( $rs );
}
=head3 cash_registers
Return Cash::Registers associated with this Library
=cut
sub cash_registers {
my ( $self ) = @_;
my $rs = $self->_result->cash_registers;
return Koha::Cash::Registers->_new_from_dbic( $rs );
}
=head2 Internal methods
=head3 _type

37
t/db_dependent/Koha/Libraries.t

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 7;
use Test::More tests => 8;
use C4::Biblio;
use C4::Context;
@ -451,3 +451,38 @@ subtest '->get_effective_marcorgcode' => sub {
$schema->storage->txn_rollback;
};
subtest 'cash_registers' => sub {
plan tests => 3;
$schema->storage->txn_begin;
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
my $register1 = $builder->build_object(
{
class => 'Koha::Cash::Registers',
value => { branch => $library->branchcode },
}
);
my $register2 = $builder->build_object(
{
class => 'Koha::Cash::Registers',
value => { branch => $library->branchcode },
}
);
my $registers = $library->cash_registers;
is( ref($registers), 'Koha::Cash::Registers',
'Koha::Library->cash_registers should return a set of Koha::Cash::Registers'
);
is( $registers->count, 2,
'Koha::Library->cash_registers should return the correct cash registers'
);
$register1->delete;
is( $library->cash_registers->next->id, $register2->id,
'Koha::Library->cash_registers should return the correct cash registers'
);
$schema->storage->txn_rollback;
};

Loading…
Cancel
Save