Bugzilla – Attachment 61015 Details for
Bug 18247
Remove SQL queries from branch_transfer_limit.pl administrative script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18247 - Added 3 successfully working unit tests for each new subroutine
Bug-18247---Added-3-successfully-working-unit-test.patch (text/plain), 4.39 KB, created by
Alex Buckley
on 2017-03-12 12:24:50 UTC
(
hide
)
Description:
Bug 18247 - Added 3 successfully working unit tests for each new subroutine
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-03-12 12:24:50 UTC
Size:
4.39 KB
patch
obsolete
>From 08cd46080a5c8566f5cc4de7b841554fd06b0e78 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Fri, 10 Mar 2017 14:46:46 +0000 >Subject: [PATCH] Bug 18247 - Added 3 successfully working unit tests for each > new subroutine > >--- > t/db_dependent/AuthorisedValues.t | 27 +++++++++++++++++++++++++-- > t/db_dependent/Koha/ItemTypes.t | 12 +++++++++++- > t/db_dependent/Koha/Libraries.t | 13 ++++++++++++- > 3 files changed, 48 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t >index 6d44a72..74b2886 100644 >--- a/t/db_dependent/AuthorisedValues.t >+++ b/t/db_dependent/AuthorisedValues.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 15; >+use Test::More tests => 17; > > use C4::Context; > use Koha::AuthorisedValue; >@@ -20,6 +20,8 @@ $dbh->do("DELETE FROM authorised_value_categories"); > Koha::AuthorisedValueCategory->new({ category_name => 'av_for_testing' })->store; > Koha::AuthorisedValueCategory->new({ category_name => 'aaav_for_testing' })->store; > Koha::AuthorisedValueCategory->new({ category_name => 'restricted_for_testing' })->store; >+Koha::AuthorisedValueCategory->new({ category_name => 'CCODE' })->store; >+ > my $av1 = Koha::AuthorisedValue->new( > { > category => 'av_for_testing', >@@ -76,6 +78,13 @@ my $av_0 = Koha::AuthorisedValue->new( > } > )->store(); > >+my $CatAuthValue = Koha::AuthorisedValue->new( >+ { >+ category => 'CCODE', >+ authorised_value => 'value 5', >+ } >+)->store(); >+ > ok( $av1->id(), 'AV 1 is inserted' ); > ok( $av2->id(), 'AV 2 is inserted' ); > ok( $av3->id(), 'AV 3 is inserted' ); >@@ -114,7 +123,7 @@ my $limits = $av1->branch_limitations; > is( @$limits, 2, 'branch_limitations functions correctly both as setter and getter' ); > > my @categories = Koha::AuthorisedValues->new->categories; >-is( @categories, 3, 'There should have 2 categories inserted' ); >+is( @categories, 4, 'There should have 4 categories inserted' ); > is( $categories[0], $av4->category, 'The first category should be correct (ordered by category name)' ); > is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' ); > >@@ -225,3 +234,17 @@ subtest 'search_by_*_field + find_by_koha_field + get_description' => sub { > ); > }; > }; >+ >+ok( $CatAuthValue->id(), 'CatAuthValue is inserted' ); >+ >+sub GetCatAuthValues { >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare('SELECT authorised_value AS ccode FROM authorised_values WHERE category = "CCODE"'); >+ $sth->execute(); >+ return $sth->rows; >+} >+ >+my $AuthValues = GetCatAuthValues(); >+is($AuthValues, 1, "Correct number of authorised_value's with category=CCODE"); >+ >+ >diff --git a/t/db_dependent/Koha/ItemTypes.t b/t/db_dependent/Koha/ItemTypes.t >index 9ce1ad6..7adf112 100755 >--- a/t/db_dependent/Koha/ItemTypes.t >+++ b/t/db_dependent/Koha/ItemTypes.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 18; >+use Test::More tests => 19; > use Data::Dumper; > use Koha::Database; > >@@ -76,4 +76,14 @@ is( $type->summary, 'summary', 'summary' ); > is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' ); > is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' ); > >+sub GetItemTypes { >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare('SELECT itemtype FROM itemtypes'); >+ $sth->execute(); >+ return $sth->rows; >+} >+ >+my $ItemTypes = GetItemTypes(); >+is($ItemTypes,10, "Correct number of itemtypes"); >+ > $schema->txn_rollback; >diff --git a/t/db_dependent/Koha/Libraries.t b/t/db_dependent/Koha/Libraries.t >index 8126b8c..3090735 100644 >--- a/t/db_dependent/Koha/Libraries.t >+++ b/t/db_dependent/Koha/Libraries.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 10; > > use Koha::Library; > use Koha::Libraries; >@@ -86,5 +86,16 @@ is( Koha::Libraries->search->count, $nb_of_libraries + 1, 'Delete should have de > $retrieved_category_2->delete; > is( Koha::LibraryCategories->search->count, $nb_of_categories + 2, 'Delete should have deleted the library category' ); > >+sub GetBranchCodes { >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ SELECT branchcode FROM branches }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute(); >+ return $sth->rows; >+} >+ >+my $BranchCodes = GetBranchCodes(); >+is($BranchCodes, 13, "Correct number of branchcodes"); >+ > $schema->storage->txn_rollback; > 1; >-- >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 18247
:
61014
|
61015
|
62583
|
62586
|
138946
|
144691