Bugzilla – Attachment 50528 Details for
Bug 16155
Composite keys in TestBuilder and more
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 16155: Adjust a few other tests
SIGNED-OFF-Bug-16155-Adjust-a-few-other-tests.patch (text/plain), 7.42 KB, created by
Bernardo Gonzalez Kriegel
on 2016-04-21 14:51:32 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 16155: Adjust a few other tests
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2016-04-21 14:51:32 UTC
Size:
7.42 KB
patch
obsolete
>From bf37e3547308a5fc459d4f3c97516e7b5fe69504 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 29 Mar 2016 15:32:24 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 16155: Adjust a few other tests > >Accounts.t: Only added a line that ensures the MPL branch exists. >AnonymiseIssueHistory.t: Only add a branch to work with. >Barcodes.t: Replaced clear with delete_all. >CalcFine.t: Remove default issuing rule and add one instead of updating. >Holds.t: Add category S in case it would not exist. >Members.t: Replaced clear with delete_all. >MoveItemFromBiblio.t: Replace last _fk construction. > >Test plan: >Run these tests. (See note). >Git grep for only_fk, {_fk} and TestBuilder::default_value. > >Note: Holds.t does not pass. Tests 9 and 39 fail, but they did already. >not ok 9 - GetReservesFromItemnumber should return a valid borrowernumber >not ok 39 - Test AlterPriority(), move to bottom >So this test needs attention, but on another report please :) > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >--- > t/db_dependent/Accounts.t | 7 +++---- > t/db_dependent/Barcodes.t | 8 ++++---- > t/db_dependent/Circulation/AnonymiseIssueHistory.t | 11 ++++++++--- > t/db_dependent/Circulation/CalcFine.t | 7 +++++++ > t/db_dependent/Holds.t | 6 ++++++ > t/db_dependent/Items/MoveItemFromBiblio.t | 11 +++++++++-- > t/db_dependent/Members.t | 3 +-- > 7 files changed, 38 insertions(+), 15 deletions(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index ee92a48..4bad302 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -52,11 +52,10 @@ my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > my $dbh = C4::Context->dbh; > >+# this test needs a MPL branch; also create another one > my $builder = t::lib::TestBuilder->new(); >- >-my $library = $builder->build({ >- source => 'Branch', >-}); >+$builder->build({ source => 'Branch', value => { branchcode => 'MPL' }}); >+my $library = $builder->build({ source => 'Branch' }); > > $dbh->do(q|DELETE FROM accountlines|); > $dbh->do(q|DELETE FROM issues|); >diff --git a/t/db_dependent/Barcodes.t b/t/db_dependent/Barcodes.t >index 9ea13af..e7a74a0 100755 >--- a/t/db_dependent/Barcodes.t >+++ b/t/db_dependent/Barcodes.t >@@ -43,8 +43,8 @@ subtest 'Test generation of annual barcodes from DB values' => sub { > > plan tests => 4; > >- $builder->clear( { source => 'Issue' } ); >- $builder->clear( { source => 'Item' } ); >+ $builder->schema->resultset( 'Issue' )->delete_all; >+ $builder->schema->resultset( 'Item' )->delete_all; > > my $barcodeobj; > >@@ -84,8 +84,8 @@ subtest 'Test generation of annual barcodes from DB values' => sub { > }; > > >-$builder->clear( { source => 'Issue' } ); >-$builder->clear( { source => 'Item' } ); >+$builder->schema->resultset( 'Issue' )->delete_all; >+$builder->schema->resultset( 'Item' )->delete_all; > > my %thash = ( > incremental => [], >diff --git a/t/db_dependent/Circulation/AnonymiseIssueHistory.t b/t/db_dependent/Circulation/AnonymiseIssueHistory.t >index f6ab089..a171897 100644 >--- a/t/db_dependent/Circulation/AnonymiseIssueHistory.t >+++ b/t/db_dependent/Circulation/AnonymiseIssueHistory.t >@@ -35,14 +35,19 @@ $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > > # TODO create a subroutine in t::lib::Mocks >-my $userenv_patron = $builder->build( { source => 'Borrower', }, ); >+my $branch = $builder->build({ source => 'Branch' }); >+my $userenv_patron = $builder->build({ >+ source => 'Borrower', >+ value => { branchcode => $branch->{branchcode} }, >+}); > C4::Context->_new_userenv('DUMMY SESSION'); > C4::Context->set_userenv( > $userenv_patron->{borrowernumber}, > $userenv_patron->{userid}, > 'usercnum', 'First name', 'Surname', >- $userenv_patron->{_fk}{branchcode}{branchcode}, >- $userenv_patron->{_fk}{branchcode}{branchname}, 0 >+ $branch->{branchcode}, >+ $branch->{branchname}, >+ 0, > ); > > my $anonymous = $builder->build( { source => 'Borrower', }, ); >diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t >index 66f2d71..862673f 100644 >--- a/t/db_dependent/Circulation/CalcFine.t >+++ b/t/db_dependent/Circulation/CalcFine.t >@@ -65,6 +65,13 @@ my $item = $builder->build( > > subtest 'Test basic functionality' => sub { > plan tests => 1; >+ >+ my $rule = $builder->schema->resultset('Issuingrule')->find({ >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => '*', >+ }); >+ $rule->delete if $rule; > my $issuingrule = $builder->build( > { > source => 'Issuingrule', >diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t >index 4ba95df..4cbf48e 100755 >--- a/t/db_dependent/Holds.t >+++ b/t/db_dependent/Holds.t >@@ -34,6 +34,12 @@ my $dbh = C4::Context->dbh; > my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode }; > my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode }; > >+# This test assumes we have a category S. This statement helps. >+$builder->build({ >+ source => 'Category', >+ value => { categorycode => 'S', category_type => 'S' }, >+}); >+ > my $borrowers_count = 5; > > $dbh->do('DELETE FROM itemtypes'); >diff --git a/t/db_dependent/Items/MoveItemFromBiblio.t b/t/db_dependent/Items/MoveItemFromBiblio.t >index b5cbdd3..29078ca 100644 >--- a/t/db_dependent/Items/MoveItemFromBiblio.t >+++ b/t/db_dependent/Items/MoveItemFromBiblio.t >@@ -23,14 +23,21 @@ use C4::Reserves; > use Koha::Database; > > use t::lib::TestBuilder; >+use Data::Dumper qw|Dumper|; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > > # NOTE This is a trick, if we want to populate the biblioitems table, we should not create a Biblio but a Biblioitem >-my $from_biblio = $builder->build( { source => 'Biblioitem', } )->{_fk}{biblionumber}; >-my $to_biblio = $builder->build( { source => 'Biblioitem', } )->{_fk}{biblionumber}; >+my $param = { source => 'Biblioitem' }; >+my $from_biblio = { >+ biblionumber => $builder->build($param)->{biblionumber}, >+}; >+my $to_biblio = { >+ biblionumber => $builder->build($param)->{biblionumber}, >+}; >+ > my $item1 = $builder->build( > { source => 'Item', > value => { biblionumber => $from_biblio->{biblionumber}, }, >diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t >index e369128..90e6536 100755 >--- a/t/db_dependent/Members.t >+++ b/t/db_dependent/Members.t >@@ -262,7 +262,6 @@ $builder->build({ > }, > }); > >-#$builder->clear( { source => 'Borrower' } ); > my $borrower1 = $builder->build({ > source => 'Borrower', > value => { >@@ -343,7 +342,7 @@ $patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id > is( scalar(@$patstodel),1,'Borrower with issue not deleted by category_code and list'); > $patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } ); > is( scalar(@$patstodel),1,'Borrower with issue not deleted by expiration_date and list'); >-$builder->clear( { source => 'Issue' } ); >+$builder->schema->resultset( 'Issue' )->delete_all; > $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); > ok( scalar(@$patstodel)== 2,'Borrowers without issue deleted from list'); > $patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id => $list1->patron_list_id() } ); >-- >1.9.1
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 16155
:
49634
|
49635
|
49636
|
49637
|
49638
|
50490
|
50491
|
50492
|
50493
|
50494
|
50518
|
50525
|
50526
|
50527
| 50528 |
50529
|
50530