Bugzilla – Attachment 125565 Details for
Bug 27944
Add new stages to the article request process
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27944: Add missing tests
Bug-27944-Add-missing-tests.patch (text/plain), 5.38 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-09-30 18:07:26 UTC
(
hide
)
Description:
Bug 27944: Add missing tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-09-30 18:07:26 UTC
Size:
5.38 KB
patch
obsolete
>From 9dc92ce4ca0a6d04f0665c710f2a4875e96c6326 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 30 Sep 2021 15:05:54 -0300 >Subject: [PATCH] Bug 27944: Add missing tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/ArticleRequests.t | 25 +---- > t/db_dependent/Koha/ArticleRequest.t | 137 +++++++++++++++++++++++++++ > 2 files changed, 138 insertions(+), 24 deletions(-) > create mode 100755 t/db_dependent/Koha/ArticleRequest.t > >diff --git a/t/db_dependent/ArticleRequests.t b/t/db_dependent/ArticleRequests.t >index c647745540..b98e129e2d 100755 >--- a/t/db_dependent/ArticleRequests.t >+++ b/t/db_dependent/ArticleRequests.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use POSIX qw(strftime); > >-use Test::More tests => 55; >+use Test::More tests => 54; > use Test::MockModule; > > use t::lib::TestBuilder; >@@ -251,26 +251,3 @@ subtest 'may_article_request' => sub { > }; > > $schema->storage->txn_rollback(); >- >-subtest 'set_pending() tests' => sub { >- >- plan tests => 2; >- >- $schema->storage->txn_begin; >- >- my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); >- $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); >- >- my $ar = $builder->build_object( >- { >- class => 'Koha::ArticleRequests', >- value => { status => Koha::ArticleRequest::Status::Requested } >- } >- ); >- >- $ar->set_pending()->discard_changes; >- >- is( $ar->status, Koha::ArticleRequest::Status::Pending ); >- >- $schema->storage->txn_rollback; >-}; >diff --git a/t/db_dependent/Koha/ArticleRequest.t b/t/db_dependent/Koha/ArticleRequest.t >new file mode 100755 >index 0000000000..e4caffbdfd >--- /dev/null >+++ b/t/db_dependent/Koha/ArticleRequest.t >@@ -0,0 +1,137 @@ >+#!/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 => 5; >+use Test::MockModule; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'request() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); >+ $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); >+ >+ my $ar = $builder->build_object( >+ { class => 'Koha::ArticleRequests', >+ value => { status => Koha::ArticleRequest::Status::Pending } >+ } >+ ); >+ >+ $ar->request()->discard_changes; >+ >+ is( $ar->status, Koha::ArticleRequest::Status::Requested ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'set_pending() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); >+ $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); >+ >+ my $ar = $builder->build_object( >+ { class => 'Koha::ArticleRequests', >+ value => { status => Koha::ArticleRequest::Status::Requested } >+ } >+ ); >+ >+ $ar->set_pending()->discard_changes; >+ >+ is( $ar->status, Koha::ArticleRequest::Status::Pending ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'process() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); >+ $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); >+ >+ my $ar = $builder->build_object( >+ { class => 'Koha::ArticleRequests', >+ value => { status => Koha::ArticleRequest::Status::Requested } >+ } >+ ); >+ >+ $ar->process()->discard_changes; >+ >+ is( $ar->status, Koha::ArticleRequest::Status::Processing ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'complete() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); >+ $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); >+ >+ my $ar = $builder->build_object( >+ { class => 'Koha::ArticleRequests', >+ value => { status => Koha::ArticleRequest::Status::Requested } >+ } >+ ); >+ >+ $ar->complete()->discard_changes; >+ >+ is( $ar->status, Koha::ArticleRequest::Status::Completed ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'cancel() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); >+ $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); >+ >+ my $ar = $builder->build_object( >+ { class => 'Koha::ArticleRequests', >+ value => { status => Koha::ArticleRequest::Status::Requested } >+ } >+ ); >+ >+ $ar->cancel()->discard_changes; >+ >+ is( $ar->status, Koha::ArticleRequest::Status::Canceled ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.33.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 27944
:
119020
|
119021
|
119022
|
120454
|
122673
|
122836
|
122837
|
122838
|
122839
|
122842
|
122843
|
122857
|
122984
|
122985
|
122986
|
122987
|
122988
|
122989
|
122990
|
123710
|
123711
|
123712
|
123943
|
123944
|
123945
|
123946
|
123947
|
123948
|
123949
|
123950
|
123951
|
123952
|
124966
|
124967
|
124968
|
124969
|
124970
|
124971
|
124972
|
124973
|
124974
|
124975
|
124976
|
125158
|
125544
|
125565
|
125567
|
125762
|
125813