Bug 36480: Add Koha::Library->desks

We add an accessor for the related desks. Tests are added.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Library.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 7f7f486d94)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Tomas Cohen Arazi 2024-04-01 20:22:22 +00:00 committed by Fridolin Somers
parent d46b6d96ac
commit 0cf193f739
2 changed files with 39 additions and 1 deletions

View File

@ -24,6 +24,7 @@ use C4::Context;
use Koha::Caches;
use Koha::Database;
use Koha::Desks;
use Koha::StockRotationStages;
use Koha::SMTP::Servers;
@ -269,6 +270,19 @@ sub cash_registers {
return Koha::Cash::Registers->_new_from_dbic( $rs );
}
=head3 desks
my $desks = $library->desks;
Returns Koha::Desks associated with this library.
=cut
sub desks {
my ($self) = @_;
return Koha::Desks->_new_from_dbic( scalar $self->_result->desks );
}
=head3 get_hold_libraries
Return all libraries (including self) that belong to the same hold groups

View File

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 2;
use Test::More tests => 3;
use Koha::Database;
use Koha::AdditionalContents;
@ -161,3 +161,27 @@ subtest 'opac_info tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'desks() tests' => sub {
plan tests => 5;
$schema->storage->txn_begin;
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
my $rs = $library->desks;
is( ref($rs), 'Koha::Desks' );
is( $rs->count, 0, 'No desks' );
my $desk_1 = $builder->build_object( { class => 'Koha::Desks', value => { branchcode => $library->id } } );
my $desk_2 = $builder->build_object( { class => 'Koha::Desks', value => { branchcode => $library->id } } );
$rs = $library->desks;
is( $rs->count, 2 );
is( $rs->next->id, $desk_1->id );
is( $rs->next->id, $desk_2->id );
$schema->storage->txn_rollback;
};