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>
This commit is contained in:
parent
4360c56621
commit
0b72c3c068
2 changed files with 48 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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…
Reference in a new issue