Bugzilla – Attachment 111003 Details for
Bug 26582
Add Koha::Acquisition::Basket->close
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26582: Unit tests
Bug-26582-Unit-tests.patch (text/plain), 2.60 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-09-30 17:48:45 UTC
(
hide
)
Description:
Bug 26582: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-09-30 17:48:45 UTC
Size:
2.60 KB
patch
obsolete
>From b77c04bea49053e9b782138a3803587bdb80c81c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 30 Sep 2020 14:40:36 -0300 >Subject: [PATCH] Bug 26582: Unit tests > >--- > t/db_dependent/Koha/Acquisition/Basket.t | 76 +++++++++++++++++++++++- > 1 file changed, 75 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Acquisition/Basket.t b/t/db_dependent/Koha/Acquisition/Basket.t >index abe3d12a9f..c1d9cc1026 100755 >--- a/t/db_dependent/Koha/Acquisition/Basket.t >+++ b/t/db_dependent/Koha/Acquisition/Basket.t >@@ -19,7 +19,9 @@ > > use Modern::Perl; > >-use Test::More tests => 10; >+use Test::More tests => 12; >+use Test::Exception; >+ > use t::lib::TestBuilder; > use t::lib::Mocks; > >@@ -300,3 +302,75 @@ subtest 'orders' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'closed() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $open_basket = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Baskets', >+ value => { >+ closedate => undef >+ } >+ } >+ ); >+ >+ my $closed_basket = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Baskets', >+ value => { >+ closedate => \'NOW()' >+ } >+ } >+ ); >+ >+ ok( $closed_basket->closed, 'Closed basket is tested as closed' ); >+ ok( !$open_basket->closed, 'Open basket is tested as open' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'close() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ # Create an open basket >+ my $basket = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Baskets', >+ value => { >+ closedate => undef >+ } >+ } >+ ); >+ >+ for my $status ( qw( new ordered partial complete cancelled ) ) { >+ $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { >+ basketno => $basket->id, >+ orderstatus => $status >+ } >+ } >+ ); >+ } >+ >+ $basket->close; >+ >+ ok( $basket->closed, 'Basket is closed' ); >+ my $ordered_orders = $basket->orders->search({ orderstatus => 'ordered' }); >+ is( $ordered_orders->count, 3, 'Only open orders have been marked as ordered' ); >+ >+ throws_ok >+ { $basket->close; } >+ 'Koha::Exceptions::Acquisition::Basket::AlreadyClosed', >+ 'Trying to close an already closed basket throws an exception'; >+ >+ $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 26582
:
111003
|
111004
|
111032
|
111033
|
111528
|
111529
|
111748