Bugzilla – Attachment 109859 Details for
Bug 25670
Add useful methods to Koha::Acquisition::Orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25670: Unit tests
Bug-25670-Unit-tests.patch (text/plain), 4.86 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-09-10 18:51:13 UTC
(
hide
)
Description:
Bug 25670: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-09-10 18:51:13 UTC
Size:
4.86 KB
patch
obsolete
>From 2d9739f722144e52fc5362b3d33c967ced874d89 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 3 Jun 2020 16:58:25 -0300 >Subject: [PATCH] Bug 25670: Unit tests > >--- > t/db_dependent/Koha/Acquisition/Orders.t | 135 +++++++++++++++++++++++ > 1 file changed, 135 insertions(+) > create mode 100644 t/db_dependent/Koha/Acquisition/Orders.t > >diff --git a/t/db_dependent/Koha/Acquisition/Orders.t b/t/db_dependent/Koha/Acquisition/Orders.t >new file mode 100644 >index 0000000000..7cf6b30fd6 >--- /dev/null >+++ b/t/db_dependent/Koha/Acquisition/Orders.t >@@ -0,0 +1,135 @@ >+#!/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 => 2; >+use Test::Exception; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use Koha::Database; >+ >+my $schema = Koha::Database->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'filter_by_active() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $order_1 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { orderstatus => 'cancelled' } >+ } >+ ); >+ my $order_2 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { orderstatus => 'completed' } >+ } >+ ); >+ my $order_3 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { orderstatus => 'new' } >+ } >+ ); >+ my $order_4 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { orderstatus => 'ordered' } >+ } >+ ); >+ my $order_5 = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { orderstatus => 'partial' } >+ } >+ ); >+ >+ my $this_orders_rs = Koha::Acquisition::Orders->search( >+ { >+ ordernumber => [ >+ $order_1->ordernumber, >+ $order_2->ordernumber, >+ $order_3->ordernumber, >+ $order_4->ordernumber, >+ $order_5->ordernumber, >+ ] >+ }, >+ { >+ order_by => 'ordernumber' >+ } >+ ); >+ >+ my $rs = $this_orders_rs->filter_by_active; >+ >+ is( $rs->count, 3, 'Only new, ordered and partial orders are returned' ); >+ is( $rs->next->ordernumber, $order_3->ordernumber , 'Expected order in resultset' ); >+ is( $rs->next->ordernumber, $order_4->ordernumber , 'Expected order in resultset' ); >+ is( $rs->next->ordernumber, $order_5->ordernumber , 'Expected order in resultset' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'filter_by_id_including_transfers() tests' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $order_1 = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); >+ my $order_2 = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); >+ my $order_3 = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); >+ >+ $builder->build( >+ { >+ source => 'AqordersTransfer', >+ value => { >+ ordernumber_from => $order_1->ordernumber, >+ ordernumber_to => $order_2->ordernumber >+ } >+ } >+ ); >+ >+ my $orders_rs = Koha::Acquisition::Orders->search; >+ my $count = $orders_rs->count; >+ >+ throws_ok >+ { $orders_rs->filter_by_id_including_transfers() } >+ 'Koha::Exceptions::MissingParameter', >+ 'Exception thrown correctly'; >+ >+ $orders_rs = $orders_rs->filter_by_id_including_transfers({ ordernumber => $order_1->ordernumber }); >+ >+ is( $orders_rs->count, 2, 'The two referenced orders are returned' ); >+ is( $orders_rs->next->ordernumber, $order_2->ordernumber, 'The right order is returned' ); >+ is( $orders_rs->next->ordernumber, $order_1->ordernumber, 'The right order is returned' ); >+ >+ $orders_rs = $orders_rs->filter_by_id_including_transfers({ ordernumber => $order_2->ordernumber }); >+ >+ is( $orders_rs->count, 1, 'Only one order related to the specified ordernumber' ); >+ is( $orders_rs->next->ordernumber, $order_2->ordernumber, 'The right order is returned' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.28.0
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 25670
:
105534
|
105535
|
109859
|
109860
|
110643
|
110644
|
110700
|
110701
|
114940
|
114941
|
116141