Bugzilla – Attachment 49926 Details for
Bug 15877
C4::Barcodes does not correctly calculate db_max for 'annual' barcodes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15877 - Unit tests
Bug-15877---Unit-tests.patch (text/plain), 2.57 KB, created by
Nick Clemens (kidclamp)
on 2016-04-05 18:52:37 UTC
(
hide
)
Description:
Bug 15877 - Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-04-05 18:52:37 UTC
Size:
2.57 KB
patch
obsolete
>From 85381598feb080a6b162020087b995d8c266114e Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 24 Feb 2016 17:56:23 +0000 >Subject: [PATCH] Bug 15877 - Unit tests > >Signed-off-by: Srdjan <srdjan@catalyst.net.nz> >--- > t/db_dependent/Barcodes.t | 60 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 59 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Barcodes.t b/t/db_dependent/Barcodes.t >index d987bd5..f992eb6 100755 >--- a/t/db_dependent/Barcodes.t >+++ b/t/db_dependent/Barcodes.t >@@ -17,8 +17,12 @@ > > use Modern::Perl; > >-use Test::More tests => 73; >+use Test::More tests => 74; > use Test::Warn; >+use Test::MockModule; >+use t::lib::TestBuilder; >+ >+use Koha::Database; > > $| = 1; > >@@ -28,6 +32,60 @@ BEGIN { > use_ok('C4::Barcodes'); > } > >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+ >+my $dbh = C4::Context->dbh; >+ >+subtest 'Test generation of annual barcodes' => sub { >+ >+ plan tests => 4; >+ >+ $dbh->do(q|DELETE FROM issues|); >+ $dbh->do(q|DELETE FROM items|); >+ >+ my $barcodeobj; >+ >+ warning_like { $barcodeobj = C4::Barcodes->new('annual') } qr/at C4\/Barcodes.pm line 123./, "(annual) Warn on barcode generated when none in DB"; >+ >+ my $barcodevalue = $barcodeobj->value(); >+ >+ my $item_1 = $builder->build({ >+ source => 'Item', >+ value => { >+ barcode => $barcodevalue >+ } >+ }); >+ >+ is($barcodevalue,$barcodeobj->db_max(), "(annual) First barcode saved to db is equal to db_max" ); >+ >+ #This is just setting the value ahead an arbitrary amount before adding a second barcode to db >+ $barcodevalue = $barcodeobj->next_value(); >+ $barcodevalue = $barcodeobj->next_value($barcodevalue); >+ $barcodevalue = $barcodeobj->next_value($barcodevalue); >+ $barcodevalue = $barcodeobj->next_value($barcodevalue); >+ $barcodevalue = $barcodeobj->next_value($barcodevalue); >+ >+ my $item_2 = $builder->build({ >+ source => 'Item', >+ value => { >+ barcode => $barcodevalue >+ } >+ }); >+ >+ $barcodeobj = C4::Barcodes->new('annual'); >+ >+ is($barcodevalue,$barcodeobj->db_max(), '(annual) db_max should equal the greatest barcode in the db when more than 1 present'); >+ ok($barcodeobj->value() gt $barcodevalue, '(annual) new barcode object should be created with value greater and last value inserted into db'); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+$dbh->do(q|DELETE FROM issues|); >+$dbh->do(q|DELETE FROM items|); >+ > my %thash = ( > incremental => [], > annual => [], >-- >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 15877
:
48363
|
48365
|
48367
|
49197
|
49198
|
49600
|
49926
|
49927
|
49928
|
49961
|
49962