Bugzilla – Attachment 97674 Details for
Bug 24459
Overloaded ->to_api needs to pass $params through
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24459: Regression tests
Bug-24459-Regression-tests.patch (text/plain), 4.43 KB, created by
Jonathan Druart
on 2020-01-21 16:04:38 UTC
(
hide
)
Description:
Bug 24459: Regression tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-01-21 16:04:38 UTC
Size:
4.43 KB
patch
obsolete
>From 69559ce0dacf61dcbe95f00957cf2e70f4ebad50 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 20 Jan 2020 09:47:18 -0300 >Subject: [PATCH] Bug 24459: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Koha/Acquisition/Invoice.t | 70 +++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Patron.t | 40 +++++++++++++++++- > 2 files changed, 109 insertions(+), 1 deletion(-) > create mode 100644 t/db_dependent/Koha/Acquisition/Invoice.t > >diff --git a/t/db_dependent/Koha/Acquisition/Invoice.t b/t/db_dependent/Koha/Acquisition/Invoice.t >new file mode 100644 >index 0000000000..e99f01f1c3 >--- /dev/null >+++ b/t/db_dependent/Koha/Acquisition/Invoice.t >@@ -0,0 +1,70 @@ >+#!/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::MockModule; >+ >+use t::lib::TestBuilder; >+ >+use Koha::Database; >+use Koha::DateUtils qw(dt_from_string); >+ >+use_ok('Koha::Acquisition::Invoice'); >+ >+my $schema = Koha::Database->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'to_api() tests' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $invoice_class = Test::MockModule->new('Koha::Acquisition::Invoice'); >+ $invoice_class->mock( >+ 'algo', >+ sub { return 'algo' } >+ ); >+ >+ my $invoice = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Invoices', >+ value => { >+ closedate => undef >+ } >+ } >+ ); >+ >+ my $closed = $invoice->to_api->{closed}; >+ ok( defined $closed, 'closed is defined' ); >+ ok( !$closed, 'closedate is undef, closed evaluates to false' ); >+ >+ $invoice->closedate( dt_from_string )->store->discard_changes; >+ $closed = $invoice->to_api->{closed}; >+ ok( defined $closed, 'closed is defined' ); >+ ok( $closed, 'closedate is defined, closed evaluates to true' ); >+ >+ my $invoice_json = $invoice->to_api({ embed => { algo => {} } }); >+ ok( exists $invoice_json->{algo} ); >+ is_deeply( $invoice_json->{algo}, 'algo' ); >+ >+ $schema->storage->txn_rollback; >+}; >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index adfcb60898..63b77c1573 100644 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,10 +19,11 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::Exception; > > use Koha::Database; >+use Koha::DateUtils qw(dt_from_string); > use Koha::Patrons; > use Koha::Patron::Relationships; > >@@ -154,3 +155,40 @@ subtest 'add_enrolment_fee_if_needed() tests' => sub { > $schema->storage->txn_rollback; > }; > }; >+ >+subtest 'to_api() tests' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron_class = Test::MockModule->new('Koha::Patron'); >+ $patron_class->mock( >+ 'algo', >+ sub { return 'algo' } >+ ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ debarred => undef >+ } >+ } >+ ); >+ >+ my $restricted = $patron->to_api->{restricted}; >+ ok( defined $restricted, 'restricted is defined' ); >+ ok( !$restricted, 'debarred is undef, restricted evaluates to false' ); >+ >+ $patron->debarred( dt_from_string->add( days => 1 ) )->store->discard_changes; >+ $restricted = $patron->to_api->{restricted}; >+ ok( defined $restricted, 'restricted is defined' ); >+ ok( $restricted, 'debarred is defined, restricted evaluates to true' ); >+ >+ my $patron_json = $patron->to_api({ embed => { algo => {} } }); >+ ok( exists $patron_json->{algo} ); >+ is( $patron_json->{algo}, 'algo' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.11.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 24459
:
97621
|
97622
| 97674 |
97675