Bugzilla – Attachment 11339 Details for
Bug 5327
Omnibus for unit tests required for all C4 modules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5327 : Added a few more lines of code to the ItemType.t unit test
Bug-5327--Added-a-few-more-lines-of-code-to-the-It.patch (text/plain), 2.50 KB, created by
Kyle M Hall (khall)
on 2012-08-03 15:37:46 UTC
(
hide
)
Description:
Bug 5327 : Added a few more lines of code to the ItemType.t unit test
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2012-08-03 15:37:46 UTC
Size:
2.50 KB
patch
obsolete
>From 13df109578a4fcd361da4e42c1a0328ee41648eb Mon Sep 17 00:00:00 2001 >From: Bart Jorgensen <bart.tj@gmail.com> >Date: Mon, 30 Jul 2012 20:10:02 +1200 >Subject: [PATCH] Bug 5327 : Added a few more lines of code to the ItemType.t unit test > >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/ItemType.t | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- > 1 files changed, 55 insertions(+), 2 deletions(-) > >diff --git a/t/ItemType.t b/t/ItemType.t >index de7a4e2..a571394 100755 >--- a/t/ItemType.t >+++ b/t/ItemType.t >@@ -5,10 +5,63 @@ > > use strict; > use warnings; >- >-use Test::More tests => 1; >+use DBI; >+use Test::More tests => 15; >+use Test::MockModule; > > BEGIN { > use_ok('C4::ItemType'); > } > >+ >+my $module = new Test::MockModule('C4::Context'); >+$module->mock('_new_dbh', sub { >+ my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) >+ || die "Cannot create handle: $DBI::errstr\n"; >+ return $dbh }); >+ >+# Mock data >+my $itemtypes = [ >+ ['itemtype','description','rentalcharge','notforloan','imageurl','summary'], >+ ['BK','Books',0,0,'',''], >+ ['CD','CDRom',0,0,'',''] >+ ]; >+ >+ >+my $dbh = C4::Context->dbh(); >+ >+my @itemtypes = C4::ItemType->all(); >+is(@itemtypes, 0, 'Testing all itemtypes is empty'); >+ >+# This should run exactly one query so we can test >+my $history = $dbh->{mock_all_history}; >+is(scalar(@{$history}), 1, 'Correct number of statements executed') ; >+ >+ >+# Now lets mock some data >+$dbh->{mock_add_resultset} = $itemtypes; >+ >+@itemtypes = C4::ItemType->all(); >+is(@itemtypes, 2, 'ItemType->all should return an array with 2 elements'); >+ >+is($itemtypes[0]->fish,undef,'Calling a bad descriptor gives undef'); >+ >+is($itemtypes[0]->itemtype, 'BK', 'First itemtype is bk'); >+ >+is($itemtypes[1]->itemtype, 'CD', 'second itemtype is cd'); >+ >+is($itemtypes[0]->description, 'Books', 'First description is books'); >+ >+is($itemtypes[1]->description, 'CDRom', 'second description is CDRom'); >+ >+is($itemtypes[0]->rentalcharge, '0', 'first rental charge is 0'); >+ >+is($itemtypes[1]->rentalcharge, '0', 'second rental charge is 0'); >+ >+is($itemtypes[0]->notforloan, '0', 'first not for loan is 0'); >+ >+is($itemtypes[1]->notforloan, '0', 'second not for loan is 0'); >+ >+is($itemtypes[0]->imageurl, '', 'first not for loan is undef'); >+ >+is($itemtypes[1]->imageurl, '', 'second not for loan is undef'); >-- >1.7.2.5
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 5327
:
2716
|
2726
|
5485
|
6236
|
6237
|
6373
|
6560
|
6561
|
6562
|
6563
|
6613
|
6614
|
6616
|
6620
|
6621
|
6622
|
6643
|
6650
|
6655
|
6679
|
6681
|
6682
|
6683
|
6726
|
6727
|
6728
|
6729
|
6730
|
6731
|
6732
|
6795
|
6799
|
6805
|
6819
|
6826
|
6827
|
6828
|
6834
|
7179
|
7180
|
7181
|
7182
|
7183
|
7184
|
7185
|
7186
|
7187
|
7188
|
7189
|
7190
|
7191
|
7192
|
7194
|
7195
|
7203
|
7206
|
7208
|
7209
|
7220
|
7221
|
7222
|
7223
|
7224
|
7225
|
7226
|
7227
|
7228
|
7229
|
7230
|
7231
|
7232
|
7233
|
7234
|
7235
|
7236
|
7237
|
7238
|
7239
|
7240
|
7241
|
7242
|
7400
|
7402
|
7403
|
7405
|
7573
|
7592
|
7593
|
7594
|
9897
|
10234
|
10616
|
10656
|
10659
|
10660
|
10661
|
10680
|
11141
|
11186
|
11212
|
11213
|
11278
|
11279
|
11280
|
11281
|
11339
|
11340
|
11341
|
11440
|
11467
|
11469
|
11470
|
11471
|
11472
|
11473
|
11500
|
11503
|
11505
|
11506
|
11633
|
11762
|
11763
|
11764
|
11765
|
11846
|
11985
|
11993
|
12002
|
12003