View | Details | Raw Unified | Return to bug 30830
Collapse All | Expand All

(-)a/Koha/Import/Record/Item.pm (+44 lines)
Line 0 Link Here
1
package Koha::Import::Record::Item;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Import::Record::Item - Koha Import Record Item Object class
29
30
=head1 API
31
32
=head2 Internal methods
33
34
=head3 _type
35
36
Returns name of corresponding DBIC resultset
37
38
=cut
39
40
sub _type {
41
    return 'ImportItem';
42
}
43
44
1;
(-)a/Koha/Import/Record/Items.pm (+56 lines)
Line 0 Link Here
1
package Koha::Import::Record::Items;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use Koha::Import::Record::Item;
25
26
use base qw(Koha::Objects);
27
28
=head1 NAME
29
30
Koha::Import::Record::Items - Koha Import Record Items Object set class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'ImportItem';
44
}
45
46
=head3 object_class
47
48
Koha::Object class
49
50
=cut
51
52
sub object_class {
53
    return 'Koha::Import::Record::Item';
54
}
55
56
1;
(-)a/Koha/Schema/Result/ImportItem.pm (+6 lines)
Lines 120-125 __PACKAGE__->belongs_to( Link Here
120
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53
120
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53
121
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GaUyqPnOhETQO8YuuKvfNQ
121
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GaUyqPnOhETQO8YuuKvfNQ
122
122
123
sub koha_object_class {
124
    'Koha::Import::Record::Item';
125
}
126
sub koha_objects_class {
127
    'Koha::Import::Record::Items';
128
}
123
129
124
# You can replace this text with custom content, and it will be preserved on regeneration
130
# You can replace this text with custom content, and it will be preserved on regeneration
125
1;
131
1;
(-)a/t/db_dependent/Koha/Import/Record/Items.t (+46 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2020 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 3;
23
24
use Koha::Import::Record::Items;
25
use Koha::Database;
26
27
use t::lib::TestBuilder;
28
29
my $schema = Koha::Database->new->schema;
30
$schema->storage->txn_begin;
31
32
my $builder = t::lib::TestBuilder->new;
33
my $nb_of_record_items = Koha::Import::Record::Items->search->count;
34
35
my $record_item_1 = $builder->build({ source => 'ImportItem' });
36
my $record_item_2 = $builder->build({ source => 'ImportItem' });
37
38
is( Koha::Import::Record::Items->search->count, $nb_of_record_items + 2, 'The 2 record items should have been added' );
39
40
my $retrieved_record_item_1 = Koha::Import::Record::Items->search({ import_items_id => $record_item_1->{import_items_id}})->next;
41
is_deeply( $retrieved_record_item_1->unblessed, $record_item_1, 'Find a record item by import items id should return the correct record item' );
42
43
$retrieved_record_item_1->delete;
44
is( Koha::Import::Record::Items->search->count, $nb_of_record_items + 1, 'Delete should have deleted the record item' );
45
46
$schema->storage->txn_rollback;
(-)a/t/lib/TestBuilder.pm (-1 / +4 lines)
Lines 605-610 sub _gen_default_values { Link Here
605
            issue_id => undef, # It should be a FK but we removed it
605
            issue_id => undef, # It should be a FK but we removed it
606
                               # We don't want to generate a random value
606
                               # We don't want to generate a random value
607
        },
607
        },
608
        ImportItem => {
609
            status => 'staged',
610
            import_error => undef
611
        },
608
    };
612
    };
609
}
613
}
610
614
611
- 

Return to bug 30830