Bugzilla – Attachment 194102 Details for
Bug 41462
Koha objects namespace for OAI sets and biblios
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41462: (QA follow-up) Add basic unit tests and koha_object_class methods
e78b966.patch (text/plain), 5.15 KB, created by
Kyle M Hall (khall)
on 2026-02-27 12:48:10 UTC
(
hide
)
Description:
Bug 41462: (QA follow-up) Add basic unit tests and koha_object_class methods
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2026-02-27 12:48:10 UTC
Size:
5.15 KB
patch
obsolete
>From e78b9667bb3a88f14bfa7a5a35abf291cd187c41 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 27 Feb 2026 07:45:28 -0500 >Subject: [PATCH] Bug 41462: (QA follow-up) Add basic unit tests and > koha_object_class methods > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Schema/Result/OaiSet.pm | 10 ++- > Koha/Schema/Result/OaiSetsBiblio.pm | 10 ++- > t/db_dependent/Koha/OAI_Sets.t | 110 ++++++++++++++++++++++++++++ > 3 files changed, 128 insertions(+), 2 deletions(-) > create mode 100755 t/db_dependent/Koha/OAI_Sets.t > >diff --git a/Koha/Schema/Result/OaiSet.pm b/Koha/Schema/Result/OaiSet.pm >index 4081a97bcce..7c59b0e5d9d 100644 >--- a/Koha/Schema/Result/OaiSet.pm >+++ b/Koha/Schema/Result/OaiSet.pm >@@ -129,6 +129,14 @@ __PACKAGE__->has_many( > # Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-07-08 15:06:22 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ju63fVMgLPbeFxeZJsQHRQ > >+=head2 koha_object_class >+ >+Returns the Koha::Object class for this table >+ >+=cut >+ >+sub koha_object_class { >+ return 'Koha::OAI::Set'; >+} > >-# You can replace this text with custom content, and it will be preserved on regeneration > 1; >diff --git a/Koha/Schema/Result/OaiSetsBiblio.pm b/Koha/Schema/Result/OaiSetsBiblio.pm >index 70409ef09c8..4ec65b79a83 100644 >--- a/Koha/Schema/Result/OaiSetsBiblio.pm >+++ b/Koha/Schema/Result/OaiSetsBiblio.pm >@@ -78,6 +78,14 @@ __PACKAGE__->belongs_to( > # Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-07-08 15:06:22 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oGVUyyyune8FVOj504xizw > >+=head2 koha_object_class >+ >+Returns the Koha::Object class for this table >+ >+=cut >+ >+sub koha_object_class { >+ return 'Koha::OAI::Set::Biblio'; >+} > >-# You can replace this text with custom content, and it will be preserved on regeneration > 1; >diff --git a/t/db_dependent/Koha/OAI_Sets.t b/t/db_dependent/Koha/OAI_Sets.t >new file mode 100755 >index 00000000000..110df3ed2dd >--- /dev/null >+++ b/t/db_dependent/Koha/OAI_Sets.t >@@ -0,0 +1,110 @@ >+#!/usr/bin/perl >+ >+# Copyright 2025 Aleisha Amohia <aleisha@catalyst.net.nz> >+# >+# 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 <https://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 3; >+use Test::Exception; >+ >+use Test::NoWarnings; >+ >+use t::lib::TestBuilder; >+ >+use Koha::Database; >+use Koha::OAI::Set; >+use Koha::OAI::Sets; >+use Koha::OAI::Set::Biblio; >+use Koha::OAI::Set::Biblios; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+$schema->storage->txn_begin; >+ >+subtest 'Koha::OAI::Set(s) tests' => sub { >+ plan tests => 5; >+ >+ my $nb_of_sets = Koha::OAI::Sets->search->count; >+ my $new_set = Koha::OAI::Set->new( >+ { >+ spec => 'test_spec', >+ name => 'Test Set', >+ } >+ )->store; >+ >+ ok( $new_set->id, 'New set should have an ID' ); >+ is( Koha::OAI::Sets->search->count, $nb_of_sets + 1, 'One set should have been added' ); >+ >+ my $retrieved_set = Koha::OAI::Sets->find( $new_set->id ); >+ is( $retrieved_set->name, 'Test Set', 'Retrieved set name should match' ); >+ >+ $retrieved_set->name('Updated Name')->store; >+ is( Koha::OAI::Sets->find( $new_set->id )->name, 'Updated Name', 'Set name should be updated' ); >+ >+ $retrieved_set->delete; >+ is( Koha::OAI::Sets->search->count, $nb_of_sets, 'Set should have been deleted' ); >+}; >+ >+subtest 'Koha::OAI::Set::Biblio(s) tests' => sub { >+ plan tests => 4; >+ >+ my $new_set = Koha::OAI::Set->new( >+ { >+ spec => 'test_spec_biblio', >+ name => 'Test Set Biblio', >+ } >+ )->store; >+ >+ my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); >+ >+ my $new_set_biblio = Koha::OAI::Set::Biblio->new( >+ { >+ set_id => $new_set->id, >+ biblionumber => $biblio->biblionumber, >+ } >+ )->store; >+ >+ ok( $new_set_biblio, 'New set biblio object created' ); >+ >+ my $retrieved_set_biblio = Koha::OAI::Set::Biblios->find( >+ { >+ set_id => $new_set->id, >+ biblionumber => $biblio->biblionumber >+ } >+ ); >+ ok( $retrieved_set_biblio, 'Retrieved set biblio object' ); >+ >+ $retrieved_set_biblio->delete; >+ ok( >+ !Koha::OAI::Set::Biblios->find( >+ { >+ set_id => $new_set->id, >+ biblionumber => $biblio->biblionumber >+ } >+ ), >+ 'Set biblio should have been deleted' >+ ); >+ >+ $new_set->delete; >+ ok( !Koha::OAI::Sets->find( $new_set->id ), 'Set should have been deleted' ); >+}; >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >2.50.1 (Apple Git-155) >
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 41462
:
190564
|
190609
|
190639
|
194101
| 194102