This patch makes the hook be passed the Koha::Checkout object instead
of a hand-crafted list of attributes.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This patch generalizes the hook so it can be used by other circulation
actions.
Tests are also simplified by mocking some of the (extensive) plugin
hooks.
To test:
1. Repeat the test plan on the original patch
=> SUCCESS: All good
2. Sign off :-D
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This patch adds tests fr a new circulation hook for plugins.
In this case the post_renewal_action hook,
The tests add the hook to the Test plugin, and verify that all the
required parameters are passed for the plugin hook to use them.
It relies on throwing an exception that is to be caught.
Sponsored-by: ByWater Solutions
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
I am really struggling finding the problem here.
Posting the source of the page may help.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
https://framapic.org/ is closing
"""
Framapic will be closing its doors on Tuesday, January 12, 2021. You will find a similar service on this page.
Uploading images is now disabled, but you can still retrieve your images on the My images page.
"""
https://framablog.org/2019/09/26/lets-de-frama-tify-the-internet/https://framablog.org/2020/03/03/10-bonnes-raisons-de-fermer-certains-services-framasoft-la-5e-est-un-peu-bizarre/
(French)
We can still use another service. However we may think about hosting the
service ourself!
Test plan:
Modify a selenium script to make it fail (for instance modify the path
for a find_element call)
Run it
Confirm that the screenshot has been uploaded correctly and that the
link works
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
The API related tests still don't pass with the previous modifications.
They pass on D10 but fail on U18 and I did not manage to find where the
problems come from.
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This is a try to fix failures in both
t/db_dependent/Template/Plugin/Branches.t
t/db_dependent/Koha/Biblio.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This patch adds tests the new RESTPublicAnonymousRequests syspref
doesn't apply to routes added by plugins.
It is up to the plugin developer to handle those conditions.
To test:
1. Apply this patch
2. Run:
$ kshell
k$ prove t/db_dependent/Koha/REST/Plugin/PluginRoutes.t
=> FAIL: Notice the tests fail
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
# Failed test 'check_password hook tests'
# at t/db_dependent/Koha/Plugins/Patron.t line 83.
[The password was rejected by a plugin]# Looks like your test exited with 255 just after 5.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
We are done with AddItem, only need to log and index.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Remove a few last references to branchprinter, mostly from tests.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
As statistics does not have a PK we need to adjust the TestBuilder
tests.
Bug 18441 already exists for adding the PK.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
deletedborrowers does not have a PK, and adding it is out of the scope
of this patchset. Indeed we will have to handle possible duplication of
borrowernumber values, which does not seem trivial.
Having bug 20271 in mind, we will have to deal with this problematic
anyway later.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
To make sure this kind of random failures will not appear in a future we
are going to fix it at TestBuilder level.
Test plan:
prove t/db_dependent/TestBuilder.t
and confirm it returns green
You could also only apply the tests against master, run them several
times and confirm that they fail most of the time.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This minimal class encapsulates the tabs to be passed around to the
templates, so error checking on missing bits is done in a single place.
It throws exceptions on errors
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
We should use build_sample item (from bug 21971) to create items,
otherwise we may not have a valid biblioitem and/or MARC record.
Test plan:
Set SearchEngine to ES
prove that the tests in Circulation.t now pass
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
The QA tools don't current recognise the WHILE directive used in this
template update. This patch adds the keyword to the list of recognised
directives and thus allows through unfiltered variables during QA runs.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
The find method in RefundLostItemFeeRules had been overloaded to only
support a hash being passed, however find can be called with a bare
array of primary key values (i.e. id in this case). TestBuilder relies
on this functionality and started to fail; This patch simply restores
the original behaviour for when a single value (or array of values) is
passed.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This patch introduces tests for new plugin hooks added to
C4::Biblio::{Add|Mod|Del}Biblio and C4::Items::{Add|Mod|Del}Item.
They are tested together as for creating an item you need to first create
a biblio and tests looks basically the same.
The testing strategy is
- Make sure the plugin is passed the right params
- Throw an exception at plugin-level, to be trapped by the C4::Biblio
and C4::Items lib, and converted into a warning. So we test for the
warning.
- Also, the fact that C4::Biblio and C4::Items warns, means the
exception was cought, and then Koha won't break on faulty plugins or
fatal errors from plugins.
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This patch implements bug 15339 for build_object.
We want it to warn if the call is wrong.
Test plan:
Make sure the tests are still returning green
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
I have no idea why this only appears today but TestBuilder generates dates using DateTime->now,
which does not take into account the timezone.
It has been highlights by a failing test today on U18.
Why today whereas this patch was pushed few weeks ago?
Why U18 and not D9?
The output of the test is:
koha_1 | # Failed test 'With BorrowerLogs and TrackLastPatronActivity we should not spam the logs'
koha_1 | # at t/db_dependent/Koha/Patrons.t line 1421.
koha_1 | # got: '2'
koha_1 | # expected: '1'
koha_1 | # Looks like you failed 1 test of 4.
koha_1 |
koha_1 | # Failed test 'BorrowersLog tests'
koha_1 | # at t/db_dependent/Koha/Patrons.t line 1422.
koha_1 | # Looks like you failed 1 test of 33.
koha_1 | [19:51:44] t/db_dependent/Koha/Patrons.t
Actually there are 2 logs, one for the cardnumber that is expected, and on for updated_on:
"updated_on" : {
"after" : "2019-03-04 21:10:00",
"before" : "2019-03-04 18:10:00"
}
Apart from the fact that we may want to remove this updated_on field from MODIFY,
the before/after dates differ from 3 hours.
Here it's currently 18:10 and in UTC-3
To prevent such behaviors in tests (create stuffs in the future...), we should
use our Koha::DateUtils::dt_from_string method that takes care of the timezone
used in other places of Koha.
Test plan:
prove t/db_dependent/Koha/Patrons.t
May fail without this patch.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
This patch is fine in itself, but there may still be an issue around
the failing test for TrackLastPatronActivity. Reopened bug 22741.
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Test plan:
1) Play with fines, should work OK
2) Try to print receipts on fines - prinfeercpt.pl, printinvoice.pl
3) git grep getnextacctno -> no occurences
4) git grep accountno should return only:
installer/data/mysql/atomicupdate/bug_21683_remove_column_accountno.perl
installer/data/mysql/update22to30.pl
misc/release_notes/release_notes_3_10_0.txt
misc/release_notes/release_notes_3_22_0.txt
5) prove
t/db_dependent/Accounts.t
t/db_dependent/ILSDI_Services.t
t/db_dependent/Stats.t
t/db_dependent/Koha/Account.t
Rescued-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Those 2 filters should return safe output as well
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This patch adds a new method mock_userenv from t::lib::Mocks in order to
simplify the mock of the userenv.
Test plan:
prove all the test files modified by this patch
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
We certainly should not expect this filter to be used much for href, but
we have one occurrence that needs it.
Test plan:
t/template_filters.t and xt/find-missing-filters.t must return green
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Stephen Graham <s.graham4@herts.ac.uk>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Stephen Graham <s.graham4@herts.ac.uk>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
With strict SQL modes we now have TestBuilder tests that fail randomly with:
Out of range value for column 'tax_rate_on_receiving'
Out of range value for column 'discount'
We are trying to insert a value that is too high for the type defined at DB level.
It happens for discount when a value > 100 is generated. The datatype is float(6,4).
From the MySQL Doc:
"""
MySQL permits a nonstandard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D).
Here, (M,D) means than values can be stored with up to M digits in total, of which D digits may be after the decimal point.
"""
So float(6,4) does not allow 100.
To recreate easily the issue:
use t::lib::TestBuilder;
my $builder = t::lib::TestBuilder->new;
$builder->build( { source => 'Aqorder', value => { discount => 100 } } )->{discount};
To make sure this patch fixes the issue you can use this script:
use Modern::Perl;
use t::lib::TestBuilder;
my $builder = t::lib::TestBuilder->new;
my ( $real, $i ) = ( 0, 0 );
while ( $real < 100 ) {
$real = $builder->_gen_real( { info => { size => [ 6, 4 ] } } );
warn $i++;
}
warn "$i - $real";
Test plan:
0/ Does not apply this patch
1/ Run the snippet above
2/ Confirm that it fails quite quickly (constantly before 500 for me)
3/ Apply this patch
4/ Run again the script
5/ Confirm that it is stuck in an infinite loop
6/ CTRL-C :D
QA Note:
Other _gen_* subroutine may need a fix, but we will wait for them to fail
TODO:
1. Add JS check to the interface to prevent the use to enter a value > 100
2. Allow '100' as a valid value for discount (?)
Followed test plan, patch worked as described
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
See bug 21526 comments 5-7
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Only the first TT params in a href was taken into account.
This also takes care to replace into href attributes only (for instance not
title, etc.)
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
The QA script call 'missing_filters', it sounds better to keep it in
order to avoid fixing it and have a weird condition (if
module->can('subroutine_name')) to maintain
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
See bug 13618 and bug 21526.
We need a script to add missing filters, or replace wrong ones.
Test plan:
- Add unescaped variables to .tt files
- prove xt/find-missing-filters.t
will warn about them
- perl misc/devel/add_missing_filters.pl
will add the missing/wrong filters
- prove xt/find-missing-filters.t
will now be happy
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
We should have plugin hooks for the staff interface just like we have for the OPAC as detailed on bug 20181.
Test Plan:
1) Apply this patch
2) Download and install the Kitchen Sink plugin ( v2.1.19 or later )
https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.19/koha-plugin-kitchen-sink-v2.1.19.kpz
3) Install the plugin
4) Restart all the things if you can ( restart_all if you are using kohadevbox )
This will ensure the plugin takes effect right away, it should be
necessary but it won't hurt anything!
5) Load the staff intranet, notice you get an console error log message and the background
for your staff intranet is now orange ( assuming you've not customized the
staff intranet in any way )
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Test plan:
- Apply first patch
- Confirm that tests is failing (t/template_filters.t)
- Apply second patch
- Confirm that tests return green
- Apply last patch
- Confirm that prices are displayed correctly
QA step:
Edit a template and add the following 2 lines:
[% SET p = '<script>alert("foo");</script>' %]
[% x | $Price %]
=> Display '0.00'
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
To make it reusable easily from QA test tools
https://gitlab.com/koha-community/qa-test-tools/issues/3
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
It would be nice if plugins had an upgrade method to handle altering tables and such when a new version of a plugin is installed. Right now it must be done in a completely bespoke manner.
Test Plan:
1) Apply this patch
2) Download the 2 most recent releases of the Kitchen Sink plugin
https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases
3) Install the earlier release
4) Look at the configuration page, at the bottom it should say the
plugin has never been upgraded
5) Install the newer release
6) Reload the configuration page, it should now say that the plugin
was upgraded and give you the date and time of the upgrade
Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This path implements unit tests for the route-from-plugin development.
It adds the required methods to the Koha::Plugin::Test plugin
distributed along with the tests. A second plugin implementing invalid
OpenAPI specs is added (Koha::Plugin::BadAPIRoute).
Edit: I made terminology changes to make it less rude.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
It is a real pain to debug selenium errors, especially when it is
not reproducible locally.
This patch capture a screenshot when an error occurred and upload it
using the excellent lut.im service provided by framasoft
(We could host our own later).
Test plan:
Modify a selenium script to make it fails (search for find_element)
You will see a stack trace followed by a link to framapic.org
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This patch reuses the method newly added to Selenium.pm and improve
existing tests.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
If items.restricted == 1, CanBookBeIssued will not returned what we are
testing.
The easiest and global fix is to define a default value at TestBuilder
package level
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Element id=doc does not longer exist on the admin home page
The "main block" need to be localized using the new class 'main
container-fluid'
We will certainly need to improve this later.
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
The tricky part here was to find an alternative for ends-with in Xpath
version 1
Indeed there are 2 button with
"/admin/authorised_values.pl?op=add_form", and the first one was picked
(/admin/authorised_values.pl?op=add_form&category=Asort1)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
To make it reusable easily.
Test plan:
The basic_workflow.t tests should still pass after this change.
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Fix for:
Out of range value for column 'amount'
t/db_dependent/Circulation/Chargelostitem.t
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Fix for:
Data too long for column 'proccode'
t/db_dependent/Accounts.t
FIXME LATER - It's a varchar(4), must be integer!
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Fix for:
Field 'marcxml' doesn't have a default value
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Fix for:
Out of range value for column 'tax_rate'
t/db_dependent/Koha/Acquisition/Basket.t
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Fix error:
Out of range value for column 'amount'
DBD::mysql::st execute failed: Out of range value for column 'amount' at
row 1 [for Statement "INSERT INTO `account_offsets` ( `amount`,
`debit_id`, `type`) VALUES ( ?, ?, ? )" with ParamValues:
0=7925469795795194609664.000000, 1='10', 2='Manual Debit'] at
/usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.
7925469795795194609664.000000
=> Should be lower anyway
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
For instance items.replacementprice is decimal(8,2) but more than 2 decimals are generated.
It leads to issues when we compare expected objects:
# got: '135623.866142537'
# expected: '135623.87'
Test plan:
prove t/db_dependent/TestBuilder.t
must return green
Signed-off-by: Dominic Pichette <dominic@inlibro.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Somehow I have the feeling that we should allow more decimals sometimes
and perhaps have a number of decimals parameter or so. Think of fields
like currency or discount.
But the current issues justify this change.
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
# Failed test 'borrowers.updated_on should have been set to now on creating'
# at t/db_dependent/Patrons.t line 74.
# got: '2017-08-10T20:53:03'
# expected: '2017-08-10T20:53:04'
# Looks like you failed 1 test of 17.
[20:53:15] t/db_dependent/Patrons.t .....................................
The plan here is to compare the number of seconds between two dates.
If < 60 the dates are consired as identicals.
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
String::Random version 0.26 (on Jessie) does not yet support the rand_gen
parameter (0.27 does, newest is 0.29 on CPAN now).
So alt_rand is only used in determining the size on Jessie.
That might be enough though.
Adding a documention line in this regard.
Removing the obsolete max parameter.
Note: I timed alt_rand for the creation of a new Bytes::Random::Secure
object each time. But each call is about 0.1 milliseconds. So that
should be fine.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Use Bytes::Random::Secure instead of perl rand.
Return a string from 50 to 100% of $size.
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
When an id is generated by TestBuilder (branchcode for instance) and the
size of the generated string is 1, we have too many chances to get
"Violation of unique constraint in Branch".
This patch increases the number of retries to 5.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Amended to make room for follow-up.
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
When you do not supply a source and add a few wrong parameters, you
would not be warned. Because build simply returns undef.
Adding a carp and a test for that situation too.
Note: In the earlier subtest 'trivial tests' build was called without
source. This now generates a warning. We just catch if there is a warning
and test the actual warning itself later on.
Test plan:
Run t/db_dependent/TestBuilder.t
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Only value and source are allowed
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Makes TestBuilder::build() alert the user when unreognized
parameters are passed, which happens when the user supplies
the column values directly, forgetting the 'value' hash.
This patch holds the code changes. Examples of the kind of
errors that it catches are in the tests (separate patch).
Sponsored-By: Halland County Library
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Bug 18314 causes t/db/SIP/Message.t to fail (quite often) since
TestBuilder fills login_attempts with a random number. (Note: Only
when FailedLoginAttempts is non-zero.)
Trivial fix: TestBuilder should have a zero default for login_attempts.
Test plan:
Do not yet apply this patch.
Set pref FailedLoginAttempts to say 3.
Run t/db_dependent/SIP/Message.t. Might fail on the password test (CQ).
Apply this patch.
Run t/db_dependent/SIP/Message.t again. Does not fail anymore.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Changes the $id parameter to an array. (IssuingRule has three keys.)
The build_object method in TestBuilder.pm has been adjusted to pass
multiple primary key values to find.
Also adjusted the POD section to show more clearly that we accept
the same parameters as DBIx ResultSet does.
Test plan:
Run t/db_dependent/Koha/Object.t
Run t/db_dependent/Koha/Objects.t
Run t/db_dependent/TestBuilder.t
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Couldn't make the tests pass using Test::DBIx::Class, so reverted to the "usual way" since these tests are
in db_dependent anyway.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This patch adds a new method to t::lib::TestBuilder so it can return
Koha::Object-derived objects. The new method is called ->build_object
and requires the plural of the target class to be passed.
'class' is a mandatory param, and a warning is raised and undef is
returned if absent.
It accepts 'value' as the original ->build() method, and that is passed as-is
to ->build().
To test:
- Apply the patches
- Run:
$ sudo koha-shell kohadev
k$ cd kohaclone
k$ prove t/db_dependent/TestBuilder.t
=> SUCCESS: Tests pass!
- Sign off :-D
Sponsored-by: ByWater Solutions
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
We will certainly have to do something with the biblio_metadata.metadata
field later.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
The items.more_subfields_xml is set to random data (generated by
TestBuilder), and so GetMarcBiblio does not manage to embed items (if
needed).
The error is:
:1: parser error : Start tag expected, '<' not found
More precisely it explodes in
C4::Items::_parse_unlinked_item_subfields_from_xml when
MARC::Record->new_from_xml is called with an invalid xml
This patch adds a default values mechanism to TestBuilder to avoid
modifying all the existing calls.
Test plan:
Set SearchEngine to ElasticSearch
prove t/db_dependent/Circulation.pl
should return green with this patch
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
TestBuilder should not generate datetime for date columns, but only for
datetime and timestamp columns.
Test plan:
Make sure the change in t/db_dependent/TestBuilder.t are consistent.
Before this patch, 1 of the 2 tests should fail.
After this patch applied, they both should pass.
Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
The number of tests using TestBuilder is gradually growing. Once you
are familiar with its use, you will appreciate it and find yourself
using it when writing new tests. Although it works quite well, some details
still needs some polishing.
While looking at the handling of composite keys in TestBuilder, a number
of related points came up too. This patch finally ended up in setting
the following design goals:
[1] TB should not only look at the first column of a composite FK.
[2] TB should optionally create records for fixed FK values.
[3] TB should create a new record, never change an existing record.
[4] TB should respect auto_increment columns.
[5] Passing a hash for a foreign key should always imply a new record.
[6] Explicitly passing undef for a column should mean NULL.
[7] Add a delete method; it will replace the clear method.
[8] Simplify by removing $default_values, hash key _fk and param only_fk.
The comments below further clarify these points. Note that they refer to
the old behavior (before this patch) unless stated otherwise.
Comments for point 1
====================
Look at:
$builder->build({
source => 'UserPermission',
value => {
borrowernumber => $borrowerno,
module_bit => { flag => 'my flag' },
code => 'will_be_ignored',
},
});
Module_bit and code here are a composite FK to permissions.
TB ignores the value for the code column here and creates a record with a
randomized code.
But if we would pass the hash in the second column of this compound key like:
borrowernumber => $borrowerno,
module_bit => 10,
code => { code => 'new_code' },
TB would now crash when passing the hash for code thru to DBIx.
Comments for point 2
====================
Look at:
$builder->build({
source => 'UserPermission',
value => {
borrowernumber => $borrowerno,
module_bit => 99,
code => 'new_super_tool',
},
});
TB detects a fixed value for the module_bit, continues and will crash on
DBIx if the foreign keys are not found. In this case it would be friendly
to create a missing linked record.
Comments for point 3
====================
Look at:
$builder->build({
source => 'Branch',
value => { branchcode => 'CPL' },
});
If this branch already exists, this call would modify the branch record and
overwrite all columns with randomized values (expected or not). In any case,
it would be safer here to return undef than modifying an existing record.
Comments for point 4
====================
Look at:
$builder->build({
source => 'Borrower',
value => { borrowernumber => '123456789' },
});
If this number would exist, we would update (as earlier). But if this
number does not exist, we would create the record. Although that is
technically possible, I would prefer to have TB respect the auto
increment property of this column.
Comments for point 5
====================
Look at:
$builder->build({
source => 'Item',
value => { homebranch => { branchcode => 'MPL' } },
});
As discussed under point 3, we should actually not pass primary key values
if we expect to build new records. The same also holds for the deeper
(recursive) calls to build when using hashes like here for homebranch.
In this case again an existing record might be overwritten.
Comments for point 6
====================
Look at:
$builder->build({
source => 'Reserve',
value => { itemnumber => undef },
});
As you know, a reserve without an itemnumber is a biblio level hold.
Unfortunately, TB did not care about passing undefs until now. So you would
get an item level hold.
In the new situation TB will respect these explicit undefs, as long as the
corresponding foreign key column is nullable of course.
Comments for point 7
====================
This patch will allow you to delete records created by TB:
my $patron = $builder->build({ source => 'Borrower' });
$builder->delete({ source => 'Borrower', records => $patron });
Or:
$builder->delete({ source => 'Borrower', records => [ $patron, ... ] });
For safety, delete requires you to provide all primary key values in the
passed hashref(s).
Deleting all records in a table via clear is no longer supported and can
still be arranged in one statement.
Comments for point 8
====================
Current use of TestBuilder reveals that $default_values and only_fk
are not really needed. The current $default_values should imo not be in the
module anyway; if you want to use it, you could still pass it to TB:
$builder->build({ ..., value => { %defa, %your_values } });
Only_fk stops at the very last step of saving the top level record while
storing all linked records at the lower levels. Practical use is not
very obvious; it can be easily simulated by one delete statement.
The hash key _fk is now used to store all linked records one or more levels
down. It is used in a few tests to retrieve a value one level down.
Why not retrieve that one value via the database and get rid of the
whole structure?
Implementation
==============
This highlights the main changes:
The $default_value hash (with some hardcoded values for UserPermission)
is removed from the module. It was used by a test in TestBuilder.t and has
been relocated.
The value of $gen_type is returned now by sub _gen_type. (See new.)
The main change in the build method is moving the foreign keys logic to a
new subroutine _create_links. This routine now looks at all columns of a
composite FK. It checks if a linked record exists for passed values, and
it looks at NULL values.
Routine _buildColumnValues is slightly adjusted to allow for passed undef
values. The theoretically endless loop is replaced by three tries. For
composite unique constraints we only check complete sets of values.
Routine _getForeignKeys contains a check to not return the same relation
twice in case of doubled belongs_to relations in the DBIx scheme.
The eval in _storeColumnValues is removed. The autoincrement check in sub
_buildColumnValue got more priority; the handling of foreign keys has been
adjusted and a check for not-nullable columns has been added.
TEST PLAN
=========
This patch only deals with the TestBuilder module itself. In the follow-up
patches TestBuilder.t and a few other unit tests are adjusted.
[1] Do not yet apply this patch. But apply the 'OldBehavior' patch.
Verify that all tests pass. (They cover the first six design goals.)
[2] Apply this patch. Does TestBuilder still compile (perl -c)?
[3] Run the OldBehavior test again. Do all tests fail now? This means
that we got rid of all unwanted side-effects in the list of goals.
[4] Run some other tests that use TestBuilder. (See below.)
Skip the following tests; a follow-up patch deals with them.
t/db_dependent/Accounts.t
t/db_dependent/Barcodes.t
t/db_dependent/Circulation/AnonymiseIssueHistory.t
t/db_dependent/Circulation/CalcFine.t
t/db_dependent/Holds.t
t/db_dependent/Items/MoveItemFromBiblio.t
t/db_dependent/Koha/BiblioFrameworks.t
t/db_dependent/Members.t
t/db_dependent/TestBuilder.t
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
The following tests pass:
t/db_dependent/Acquisition/OrderUsers.t
t/db_dependent/Auth/haspermission.t
t/db_dependent/Barcodes_ValueBuilder.t
t/db_dependent/Budgets.t
t/db_dependent/Category.t
t/db_dependent/Circulation.t
t/db_dependent/Circulation/GetTopIssues.t
t/db_dependent/Circulation/IsItemIssued.t
t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t
t/db_dependent/Circulation/Returns.t
t/db_dependent/Circulation/TooMany.t
t/db_dependent/Circulation_dateexpiry.t
t/db_dependent/Circulation_transfers.t
t/db_dependent/CourseReserves.t
t/db_dependent/Creators/Lib.t
t/db_dependent/DecreaseLoanHighHolds.t
t/db_dependent/Exporter/Record.t
t/db_dependent/Holds/LocalHoldsPriority.t
t/db_dependent/Holds/RevertWaitingStatus.t:
t/db_dependent/HoldsQueue.t
t/db_dependent/Holidays.t
t/db_dependent/Items.t
t/db_dependent/Items_DelItem.t
t/db_dependent/Koha/Acquisition/Currencies.t
t/db_dependent/Koha/Authorities.t
t/db_dependent/Koha/BiblioFrameworks.t
t/db_dependent/Koha/Cities.t
t/db_dependent/Koha/Libraries.t
t/db_dependent/Koha/Objects.t
t/db_dependent/Koha/Patron/Categories.t
t/db_dependent/Koha/Patron/Images.t
t/db_dependent/Koha/Patron/Messages.t
t/db_dependent/Koha/Patrons.t
t/db_dependent/Koha/SMS_Providers.t
t/db_dependent/Koha_template_plugin_Branches.t
t/db_dependent/Letters.t
t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t
t/db_dependent/Members/GetUpcomingMembershipExpires.t
t/db_dependent/Members_Attributes.t
t/db_dependent/Patron/Borrower_Debarments.t
t/db_dependent/Patron/Borrower_Discharge.t
t/db_dependent/Patron/Borrower_Files.t
t/db_dependent/Ratings.t
t/db_dependent/Reports_Guided.t
t/db_dependent/Reserves/GetReserveFee.t
t/db_dependent/Review.t
t/db_dependent/Serials_2.t
t/db_dependent/ShelfBrowser.t
t/db_dependent/Virtualshelves.t
t/db_dependent/api/v1/patrons.t
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This patch removes transaction handling code from TestBuilder.
It fixes the TestBuilder.t to handle the transaction on its own.
Verify that t/db_dependent/TestBuilder.t passes.
Followed test plan, TestBuilder.t passes
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
C4::Context::_new_dbh does not exist anymore.
Koha::Database::_new_schema should be mocked instead.
Will fix:
- t/00-load.t
- t/Breeding.t
- t/ImportBatch.t
- t/Message.t
- t/Overdues.t
- t/Prices.t
- t/RotatingCollections.t
- t/Search.t
- t/SuggestionEngine_AuthorityFile.t
- t/XSLT.t
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
DBD::mysql::db begin_work failed: Already in a transaction at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1560.
DBIx::Class::Storage::DBI::txn_rollback(): Storage transaction_depth 0 does not match false AutoCommit of DBI::db=HASH(0xa429648), attempting ROLLBACK anyway at t/lib/TestBuilder.pm line 363
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
This module will be called by db_dependent tests, which already create a
transaction.
TestBuilder creates a new one (which is certainly useless) and the
rollback does not do anything.
To see the warning see patches on bug 14045.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
There were some issues in the previous patch. This patch fixes the
following:
- rename $value with $original_value
- remove $at_least_one_constraint_failed and $values_ok which make the
code unnecessarily complicated
- the constraints have to be checked only if no original value is passed
- _buildColumnValue created a key to the default value hashref, it broke
the test:
last BUILD_VALUE if exists( $default_value->{$source} );
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>