Bugzilla – Attachment 181459 Details for
Bug 39711
Migrate C4::Contract to object classes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39711: Add unit tests
Bug-39711-Add-unit-tests.patch (text/plain), 3.88 KB, created by
Matt Blenkinsop
on 2025-04-24 14:41:10 UTC
(
hide
)
Description:
Bug 39711: Add unit tests
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2025-04-24 14:41:10 UTC
Size:
3.88 KB
patch
obsolete
>From 4051b110f61f32dfc7da32c2883ab1a67fa7fbc1 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> >Date: Thu, 24 Apr 2025 15:14:22 +0100 >Subject: [PATCH] Bug 39711: Add unit tests > >--- > t/db_dependent/Koha/Acquisition/Booksellers.t | 16 ++--- > t/db_dependent/Koha/Acquisition/Contracts.t | 63 +++++++++++++++++++ > 2 files changed, 72 insertions(+), 7 deletions(-) > create mode 100755 t/db_dependent/Koha/Acquisition/Contracts.t > >diff --git a/t/db_dependent/Koha/Acquisition/Booksellers.t b/t/db_dependent/Koha/Acquisition/Booksellers.t >index 14512113598..2ce1fa5597b 100755 >--- a/t/db_dependent/Koha/Acquisition/Booksellers.t >+++ b/t/db_dependent/Koha/Acquisition/Booksellers.t >@@ -23,7 +23,6 @@ use t::lib::TestBuilder; > > use C4::Acquisition qw( NewBasket ); > use C4::Biblio qw( AddBiblio ); >-use C4::Contract qw( AddContract ); > use C4::Budgets qw( AddBudgetPeriod AddBudget ); > use C4::Serials qw( NewSubscription SearchSubscriptions ); > >@@ -270,18 +269,21 @@ subtest 'contracts' => sub { > > my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); > >- is( scalar( @{ $vendor->contracts } ), 0, 'Vendor has no contracts' ); >+ is( scalar( @{ $vendor->contracts->as_list } ), 0, 'Vendor has no contracts' ); > >- AddContract( >+ my $contract = $builder->build_object( > { >- booksellerid => $vendor->id, >- contractname => 'Test contract', >+ class => 'Koha::Acquisition::Contracts', >+ value => { >+ booksellerid => $vendor->id, >+ contractname => 'Test contract', >+ } > } > ); > > $vendor = $vendor->get_from_storage; >- my $contracts = $vendor->contracts; >- is( scalar( @{$contracts} ), 1, '1 contract stored' ); >+ my @contracts = $vendor->contracts->as_list; >+ is( scalar(@contracts), 1, '1 contract stored' ); > > $schema->storage->txn_rollback(); > }; >diff --git a/t/db_dependent/Koha/Acquisition/Contracts.t b/t/db_dependent/Koha/Acquisition/Contracts.t >new file mode 100755 >index 00000000000..81b0f67f2f7 >--- /dev/null >+++ b/t/db_dependent/Koha/Acquisition/Contracts.t >@@ -0,0 +1,63 @@ >+#!/usr/bin/perl >+# >+# 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 Test::Exception; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use Koha::Database; >+ >+use_ok('Koha::Acquisition::Contract'); >+use_ok('Koha::Acquisition::Contracts'); >+ >+my $schema = Koha::Database->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'store' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $starting_contract_count = Koha::Acquisition::Contracts->count; >+ >+ my $new_contract = Koha::Acquisition::Contract->new( >+ { >+ contractname => 'Test contract', >+ booksellerid => 1, >+ } >+ )->store; >+ my $contract_count_1 = Koha::Acquisition::Contracts->count; >+ >+ is( $contract_count_1, $starting_contract_count + 1, '1 contract stored' ); >+ >+ throws_ok { >+ my $contract_with_missing_vendor = Koha::Acquisition::Contract->new( >+ { >+ contractname => 'Test contract', >+ } >+ )->store; >+ } >+ 'Koha::Exceptions::MissingParameter', >+ >+ $schema->storage->txn_rollback; >+}; >+ >-- >2.48.1
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 39711
:
181453
|
181454
|
181455
|
181456
|
181457
|
181458
| 181459 |
181460
|
181461
|
181580
|
181581
|
181582
|
181583
|
181584
|
181586
|
181587
|
181588