Bugzilla – Attachment 73396 Details for
Bug 19520
Show more information about rotating collections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19520: Add tests
Bug-19520-Add-tests.patch (text/plain), 4.78 KB, created by
Josef Moravec
on 2018-03-28 15:35:30 UTC
(
hide
)
Description:
Bug 19520: Add tests
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2018-03-28 15:35:30 UTC
Size:
4.78 KB
patch
obsolete
>From 11e1a1a12af5c9ffec3e74d2e685de2a9093f379 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Sun, 12 Nov 2017 10:50:24 +0000 >Subject: [PATCH] Bug 19520: Add tests > >--- > t/db_dependent/Koha/RotatingCollections.t | 120 +++++++++++++++++++++++++++++- > 1 file changed, 118 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/RotatingCollections.t b/t/db_dependent/Koha/RotatingCollections.t >index 57f16ff..b3458fc 100644 >--- a/t/db_dependent/Koha/RotatingCollections.t >+++ b/t/db_dependent/Koha/RotatingCollections.t >@@ -17,17 +17,20 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 4; > use C4::Context; > use Koha::Biblios; >+use Koha::Biblioitems; > use Koha::Database; >-use Koha::Library; >+use Koha::DateUtils; > use Koha::RotatingCollections; > use Koha::Items; > use Koha::Item::Transfers; > use Koha::Libraries; >+use Koha::Patrons; > > use t::lib::TestBuilder; >+use Test::MockModule; > > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; >@@ -140,3 +143,116 @@ subtest 'transfer' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'new_create_creator' => sub { >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $collection1 = Koha::RotatingCollection->new( { >+ colTitle => "Collection 1", >+ colDesc => "Collection 1 description", >+ } )->store; >+ >+ is($collection1->creator, undef, "Creator should not be set if patron is not set in userenv"); >+ >+ my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; >+ my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; >+ >+ my $patron = Koha::Patron->new( { >+ firstname => "Creative", >+ surname => "Librarian", >+ categorycode => $categorycode, >+ branchcode => $branchcode, >+ })->store; >+ >+ my $context = new Test::MockModule('C4::Context'); >+ $context->mock('userenv', sub { >+ return { >+ number => $patron->borrowernumber, >+ } >+ }); >+ my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); >+ >+ my $collection2 = Koha::RotatingCollection->new( { >+ colTitle => "Collection 2", >+ colDesc => "Collection 2 description", >+ } )->store; >+ >+ is( $collection2->createdOn, $today , "Collection create day should be set"); >+ is( $collection2->creator->borrowernumber, $patron->borrowernumber, "Collection creator should be set"); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'untransferred_items' => sub { >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $library1 = Koha::Library->new({ >+ branchcode => "LIBCOL1", >+ branchname => "Library for testing collection 1", >+ })->store; >+ >+ my $library2 = Koha::Library->new({ >+ branchcode => "LIBCOL2", >+ branchname => "Library for testing colletions 2", >+ })->store; >+ >+ my $biblio = Koha::Biblio->new({ >+ author => "Some author 1", >+ title => "Some title 2", >+ })->store; >+ >+ my $biblioitem = Koha::Biblioitem->new({ >+ biblionumber => $biblio->biblionumber, >+ })->store; >+ >+ my $item1 = Koha::Item->new({ >+ barcode => "BC1000001", >+ biblionumber => $biblio->biblionumber, >+ biblioitemnumber => $biblioitem->biblioitemnumber, >+ homebranch => $library1->branchcode, >+ holdingbranch => $library1->branchcode, >+ })->store; >+ >+ my $item2 = Koha::Item->new({ >+ barcode => "BC1000002", >+ biblionumber => $biblio->biblionumber, >+ biblioitemnumber => $biblioitem->biblioitemnumber, >+ homebranch => $library1->branchcode, >+ holdingbranch => $library1->branchcode, >+ })->store; >+ >+ my $item3 = Koha::Item->new({ >+ barcode => "BC1000003", >+ biblionumber => $biblio->biblionumber, >+ biblioitemnumber => $biblioitem->biblioitemnumber, >+ homebranch => $library1->branchcode, >+ holdingbranch => $library1->branchcode, >+ })->store; >+ >+ my $collection = Koha::RotatingCollection->new({ >+ colTitle => "Collection", >+ colDesc => "Collection description", >+ })->store; >+ >+ is($collection->untransferred_items->count, 0, "There are no items, so no untransferred"); >+ >+ $collection->add_item( $item1 ); >+ $collection->add_item( $item2 ); >+ >+ is($collection->untransferred_items->count, 2, "We added 2 items"); >+ >+ $collection->transfer( $library2 ); >+ >+ is($collection->untransferred_items->count, 0, "There are no untransferred items after transfer"); >+ >+ $collection->add_item( $item3 ); >+ >+ is($collection->untransferred_items->count, 1, "We added 1 more item"); >+ is($collection->untransferred_items->next->itemnumber, $item3->itemnumber, "The returned item is the one added after transfer"); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.1.4
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 19520
:
72819
|
72820
|
72821
|
72822
|
73260
|
73261
|
73262
|
73263
|
73394
|
73395
| 73396 |
73397