Bug 36873: Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 2d5b3cb04b)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2024-05-15 16:12:31 -03:00 committed by Lucas Gass
parent 91ea18bf41
commit cf05d5d43a
1 changed files with 23 additions and 3 deletions

View File

@ -29,6 +29,7 @@ use C4::Context;
use Koha::Authority::Types;
use Koha::Cities;
use Koha::Biblios;
use Koha::Items;
use Koha::Patron::Category;
use Koha::Patron::Categories;
use Koha::Patrons;
@ -1285,7 +1286,7 @@ subtest 'empty() tests' => sub {
subtest 'delete() tests' => sub {
plan tests => 2;
plan tests => 3;
$schema->storage->txn_begin;
@ -1313,5 +1314,24 @@ subtest 'delete() tests' => sub {
[ "delete called!", "delete called!" ],
"No warnings, no Koha::City->delete called as it doesn't exist";
my $item_id_1 = $builder->build_sample_item()->id;
my $item_id_2 = $builder->build_sample_item()->id;
# Mock Koha::City
my $mocked_item = Test::MockModule->new('Koha::Item');
$mocked_item->mock(
'delete',
sub {
my ( $self, $params ) = @_;
warn ref($self);
warn $params->{skip_record_index};
}
);
my $items = Koha::Items->search( { itemnumber => [ $item_id_1, $item_id_2 ] } );
warning_is { $items->delete( { skip_record_index => 1 } ) }
[ "Koha::Item", "1", "Koha::Item", "1" ],
"No warnings, no Koha::City->delete called as it doesn't exist";
$schema->storage->txn_rollback;
};