Bug 17759: Remove invalid guarantorid's in Members.t
See also bug 17733. As long as we have no FK, these invalid guarantorid's
can make tests fail.
Adding a sql statement to clear them in the beginning of the test.
Test plan:
[1] Since it seems that AUTO_INC+8, +9 and +10 may fail one or two tests,
we should manipulate one or two borrowers:
Run this SQL query first:
SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '[your database]' and table_name='borrowers';
Now run: UPDATE borrowers SET guarantorid=[former value + 8] WHERE borrowernumber=[some existing borrowernumber]
[2] Without this patch, run Members.t. Should fail two tests.
[3] Apply the patch. Fetch the new AUTO_INCREMENT value and update
guarantorid accordingly again for the manipulated borrower.
[4] Run the test. It should not fail.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 82d75e124e)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
This commit is contained in:
parent
45bd59064f
commit
2820755f15
|
|
@ -39,6 +39,9 @@ my $builder = t::lib::TestBuilder->new;
|
|||
my $dbh = C4::Context->dbh;
|
||||
$dbh->{RaiseError} = 1;
|
||||
|
||||
# Remove invalid guarantorid's as long as we have no FK
|
||||
$dbh->do("UPDATE borrowers b1 LEFT JOIN borrowers b2 ON b2.borrowernumber=b1.guarantorid SET b1.guarantorid=NULL where b1.guarantorid IS NOT NULL AND b2.borrowernumber IS NULL");
|
||||
|
||||
my $library1 = $builder->build({
|
||||
source => 'Branch',
|
||||
});
|
||||
|
|
@ -263,6 +266,7 @@ my $borrower1 = $builder->build({
|
|||
categorycode=>'STAFFER',
|
||||
branchcode => $library3->{branchcode},
|
||||
dateexpiry => '2015-01-01',
|
||||
guarantorid=> undef,
|
||||
},
|
||||
});
|
||||
my $bor1inlist = $borrower1->{borrowernumber};
|
||||
|
|
@ -272,6 +276,7 @@ my $borrower2 = $builder->build({
|
|||
categorycode=>'STAFFER',
|
||||
branchcode => $library3->{branchcode},
|
||||
dateexpiry => '2015-01-01',
|
||||
guarantorid=> undef,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -281,6 +286,7 @@ my $guarantee = $builder->build({
|
|||
categorycode=>'KIDclamp',
|
||||
branchcode => $library3->{branchcode},
|
||||
dateexpiry => '2015-01-01',
|
||||
guarantorid=> undef, # will be filled later
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -294,11 +300,6 @@ $builder->build({
|
|||
},
|
||||
});
|
||||
|
||||
# In some dirty DB, the guarantorid is set to a non existent patron id
|
||||
# If we pick it, then the tests will fail
|
||||
# This should not be needed, we should have a FK on the guarantorid instead
|
||||
Koha::Patrons->search({ guarantorid => { -in => [ $borrower1->{borrowernumber}, $borrower2->{borrowernumber} ] }})->update({ guarantorid => undef });
|
||||
|
||||
my $owner = AddMember (categorycode => 'STAFFER', branchcode => $library2->{branchcode} );
|
||||
my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } );
|
||||
my @listpatrons = ($bor1inlist, $bor2inlist);
|
||||
|
|
|
|||
Loading…
Reference in New Issue