Bugzilla – Attachment 135282 Details for
Bug 30830
Add Koha Objects for Koha Import Items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30830: Add Koha Objects for Koha Import Items
Bug-30830-Add-Koha-Objects-for-Koha-Import-Items.patch (text/plain), 6.31 KB, created by
David Nind
on 2022-05-23 17:16:44 UTC
(
hide
)
Description:
Bug 30830: Add Koha Objects for Koha Import Items
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-05-23 17:16:44 UTC
Size:
6.31 KB
patch
obsolete
>From 5255ca1229de4bffa9e7fdfe3efc83ff311a93b2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 23 May 2022 12:25:53 +0000 >Subject: [PATCH] Bug 30830: Add Koha Objects for Koha Import Items > >To test: >prove -v t/db_dependent/Koha/Import/Record/Items.t > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Import/Record/Item.pm | 44 ++++++++++++++++++ > Koha/Import/Record/Items.pm | 56 +++++++++++++++++++++++ > Koha/Schema/Result/ImportItem.pm | 6 +++ > t/db_dependent/Koha/Import/Record/Items.t | 46 +++++++++++++++++++ > t/lib/TestBuilder.pm | 4 ++ > 5 files changed, 156 insertions(+) > create mode 100644 Koha/Import/Record/Item.pm > create mode 100644 Koha/Import/Record/Items.pm > create mode 100755 t/db_dependent/Koha/Import/Record/Items.t > >diff --git a/Koha/Import/Record/Item.pm b/Koha/Import/Record/Item.pm >new file mode 100644 >index 0000000000..37c5e165f4 >--- /dev/null >+++ b/Koha/Import/Record/Item.pm >@@ -0,0 +1,44 @@ >+package Koha::Import::Record::Item; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Import::Record::Item - Koha Import Record Item Object class >+ >+=head1 API >+ >+=head2 Internal methods >+ >+=head3 _type >+ >+Returns name of corresponding DBIC resultset >+ >+=cut >+ >+sub _type { >+ return 'ImportItem'; >+} >+ >+1; >diff --git a/Koha/Import/Record/Items.pm b/Koha/Import/Record/Items.pm >new file mode 100644 >index 0000000000..1f0047477e >--- /dev/null >+++ b/Koha/Import/Record/Items.pm >@@ -0,0 +1,56 @@ >+package Koha::Import::Record::Items; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::Import::Record::Item; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Import::Record::Items - Koha Import Record Items Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'ImportItem'; >+} >+ >+=head3 object_class >+ >+Koha::Object class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Import::Record::Item'; >+} >+ >+1; >diff --git a/Koha/Schema/Result/ImportItem.pm b/Koha/Schema/Result/ImportItem.pm >index 6d13719ee1..58c098c0f5 100644 >--- a/Koha/Schema/Result/ImportItem.pm >+++ b/Koha/Schema/Result/ImportItem.pm >@@ -120,6 +120,12 @@ __PACKAGE__->belongs_to( > # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GaUyqPnOhETQO8YuuKvfNQ > >+sub koha_object_class { >+ 'Koha::Import::Record::Item'; >+} >+sub koha_objects_class { >+ 'Koha::Import::Record::Items'; >+} > > # You can replace this text with custom content, and it will be preserved on regeneration > 1; >diff --git a/t/db_dependent/Koha/Import/Record/Items.t b/t/db_dependent/Koha/Import/Record/Items.t >new file mode 100755 >index 0000000000..de5b6dd916 >--- /dev/null >+++ b/t/db_dependent/Koha/Import/Record/Items.t >@@ -0,0 +1,46 @@ >+#!/usr/bin/perl >+ >+# Copyright 2020 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 3; >+ >+use Koha::Import::Record::Items; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $nb_of_record_items = Koha::Import::Record::Items->search->count; >+ >+my $record_item_1 = $builder->build({ source => 'ImportItem' }); >+my $record_item_2 = $builder->build({ source => 'ImportItem' }); >+ >+is( Koha::Import::Record::Items->search->count, $nb_of_record_items + 2, 'The 2 record items should have been added' ); >+ >+my $retrieved_record_item_1 = Koha::Import::Record::Items->search({ import_items_id => $record_item_1->{import_items_id}})->next; >+is_deeply( $retrieved_record_item_1->unblessed, $record_item_1, 'Find a record item by import items id should return the correct record item' ); >+ >+$retrieved_record_item_1->delete; >+is( Koha::Import::Record::Items->search->count, $nb_of_record_items + 1, 'Delete should have deleted the record item' ); >+ >+$schema->storage->txn_rollback; >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index bf25c89693..86a793f1b9 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -605,6 +605,10 @@ sub _gen_default_values { > issue_id => undef, # It should be a FK but we removed it > # We don't want to generate a random value > }, >+ ImportItem => { >+ status => 'staged', >+ import_error => undef >+ }, > }; > } > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30830
:
135259
|
135261
|
135282
|
135296