On bug 17591 we discovered that there was something weird going on with
the way we export and use subroutines/modules.
This patch tries to standardize our EXPORT to use EXPORT_OK only.
That way we will need to explicitely define the subroutine we want to
use from a module.
This patch is a squashed version of:
Bug 17600: After export.pl
Bug 17600: After perlimport
Bug 17600: Manual changes
Bug 17600: Other manual changes after second perlimports run
Bug 17600: Fix tests
And a lot of other manual changes.
export.pl is a dirty script that can be found on bug 17600.
"perlimport" is:
git clone https://github.com/oalders/App-perlimports.git
cd App-perlimports/
cpanm --installdeps .
export PERL5LIB="$PERL5LIB:/kohadevbox/koha/App-perlimports/lib"
find . \( -name "*.pl" -o -name "*.pm" \) -exec perl App-perlimports/script/perlimports --inplace-edit --no-preserve-unused --filename {} \;
The ideas of this patch are to:
* use EXPORT_OK instead of EXPORT
* perltidy the EXPORT_OK list
* remove '&' before the subroutine names
* remove some uneeded use statements
* explicitely import the subroutines we need within the controllers or
modules
Note that the private subroutines (starting with _) should not be
exported (and not used from outside of the module except from tests).
EXPORT vs EXPORT_OK (from
https://www.thegeekstuff.com/2010/06/perl-exporter-examples/)
"""
Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access it’s members.
@EXPORT and @EXPORT_OK are the two main variables used during export operation.
@EXPORT contains list of symbols (subroutines and variables) of the module to be exported into the caller namespace.
@EXPORT_OK does export of symbols on demand basis.
"""
If this patch caused a conflict with a patch you wrote prior to its
push:
* Make sure you are not reintroducing a "use" statement that has been
removed
* "$subroutine" is not exported by the C4::$MODULE module
means that you need to add the subroutine to the @EXPORT_OK list
* Bareword "$subroutine" not allowed while "strict subs"
means that you didn't imported the subroutine from the module:
- use $MODULE qw( $subroutine list );
You can also use the fully qualified namespace: C4::$MODULE::$subroutine
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
We shouldn't rely on knowing exactly which ISBNs we get, we should specifically
check for what we do or don't expect.
I believe we should return biblios that have the same isbn we passed, as it signlas we have another
biblio in the catalog that matches the one we are on.
To test:
prove -v t/db_dependent/XISBN.t
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
The test here was returning 0590353403 when searched for 9780590353403
because of the regex matching
Koha doesn't work this way unless SearchWithISBNVariations is set to 'search'
and you use a dropdown to select ISBN for searching
To test:
1 - Search catalog for nb=9780590353403
2 - Confirm you don't have results, or delete the records with results
3 - Add isbn 0590353403 to a record
4 - Repeat search, fails
5 - Enable SearchWithISBNVariations
6 - Repeat search, fails
7 - Go to advanced search, select ISBN, search for 9780590353403
8 - Get results
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This patch adds a .perlcriticrc (copied from qa-test-tools) and fixes
almost all perlcrictic violations according to this .perlcriticrc
The remaining violations are silenced out by appending a '## no critic'
to the offending lines. They can still be seen by using the --force
option of perlcritic
This patch also modify t/00-testcritic.t to check all Perl files using
the new .perlcriticrc.
I'm not sure if this test script is still useful as it is now equivalent
to `perlcritic --quiet .` and it looks like it is much slower
(approximatively 5 times slower on my machine)
Test plan:
1. Run `perlcritic --quiet .` from the root directory. It should output
nothing
2. Run `perlcritic --quiet --force .`. It should output 7 errors (6
StringyEval, 1 BarewordFileHandles)
3. Run `TEST_QA=1 prove t/00-testcritic.t`
4. Read the patch. Check that all changes make sense and do not
introduce undesired behaviour
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.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: Michal Denar <black23@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
For a biblio with multiple ISBNS we sometimes get our own record back when
check XISBN, we should test for this
To test:
1 - Edit a record in the catalogue, add two isbns:
0521240670
0521284198
2 - Enable ThingISBN and FRBRizeEditions and OPACFRBRizeEditions
3 - View the record in staff and OPAC
4 - You should see editions tab pointing to the same record
5 - Apply patch
6 - Reload the record details, you should no longer see editions tab
7 - Add the second ISBN to another record
8 - Reload details for original record, you shoudl see editions linking to the record with second ISBN
9 - prove -v t/db_dependent/XISBN.t
NOTE: Current tests don't work under elasticsearch, but the code does, tests should be rewritten on another bug
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com>
Signed-off-by: Arthur Bousquet <arthur.bousquet@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
And use a DBIx transaction instead.
Test plan:
prove that the test files modified by this patch are passing
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Remove:
- BIB_INDEX_MODE and AUTH_INDEX_MODE env var
- bib_index_mode and auth_index_mode options from scripts
- Warnings from about page, just kept one if zebra_bib_index_mode or
zebra_auth_index_mode still exist in config and are set to grs1
Test plan:
- Install Koha from src
- Install Koha from pkg
- Read the code, carefully!
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Rebased
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
OCLC has decided to retire all xISBN services:
https://www.oclc.org/developer/news/2018/xid-decommission.en.html
The code for related features has to be removed from Koha.
Test plan:
You need to be familiar with the different sysprefs (I am not):
- FRBRizeEditions
- SyndeticsEnabled
- SyndeticsEditions
- ThingISBN
Make sure there are no regressions introduced by this patchset.
QA Note: C4/XISBN.pm should be renammed
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
To test:
1 - grep get_biblionumber_from_isbn
2 - verify all occurences are not actual calls (except for test)
3 - Apply patch
4 - grep get_biblionumber_from_isbn
5 - Verify it is removed
Signed-off-by: Roch D'Amour <roch.damour@inlibro.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This patch makes C4::XISBN::get_xisbns() return an errors hashref
including information of the failing fetches from xisbn services.
It tackles the situation of XISBN, which in some cases returns 'overlimit'
errors.
The patch makes the relevant functions check if the response->{stat} string
is 'ok' and returns the string in $errors otherwise.
This only happens when in list context. This allows to fix the randomly failing
tests while keeping the current behaviour.
All this code should be rewritten. It does the job bug doesn't have problems handling
or reoprting. This is just a band aid.
To test:
- Make sure
k$ prove t/db_dependent/XISBN.t
=> SUCCESS :-D
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Unless in t/db_dependent/Context.t where we want to test the cache
behaviors.
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
It seems that XISBN is failing sometimes, if you run the tests a couple
of times in a row. An error 500 is raised by lwp.
This problem should be trapped and related tests skipped. Because too much
noise could make people pay no attention to this tests failing.
To reproduce:
- Run the tests several consecutive times:
$ prove -v t/db_dependent/XISBN.t
=> FAIL: XISBN test will fail eventually, printing a networking-related warning.
- Apply the patch
- Repeat the test
=> SUCCESS: when XISBN the networking/connection refused problem arises, the test
is skipped, and it still passes.
Regards
To+
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
To test:
- Have a DOM setup
- Run
$ prove -v t/db_dependent/XISBN.t
=> FAIL: Can't call method "field" on an undefined value at .... C4/Search.pm ...
- Apply the patch
- Run
$ prove -v t/db_dependent/XISBN.t
=> SUCCESS: Tests pass.
- Sign off
Regards
To+
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
The set of related ISBNs for the first Harry Potter book returned
by OCLC's XISBN service has changed recently, so this patch adjusts
the test to match.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This UT got wrapped inside a transaction with autocommit=0 but
the rollback call was inadvertedly ommited. Adding it.
[RM note: an explicit rollback is not required, as the
transaction will roll back automatically at the end of
the DB session. Nonetheless, it hurts nothing to have
it be explicit.]
Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
The tests should be executed into a transaction and the SimpleSearch
routine correctly mocked.
Test plan:
Verify that prove t/db_dependent/XISBN.t returns green.
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
A unit test fails in t/db_dependent/XISBN.t, the get_xisbn routine, if
ThingISBN is enabled, returns the 3rd biblionumber, not the second one.
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Makefile.PL: Section for creating file t/test-config.txt removed.
Removes t/Makefile and t/rewrite-config-test too.
Modifies XISBN.t to remove two commented lines.
Test plan:
Grep for KohaTest, database_dependent, config-test, t/Makefile.
Run perl Makefile.PL and include running the test suite.
This may fail on t/00-valid-xml.t and t/QueryParser.t, but that is not the
result of this patch. Same for t/00-load.t with potential error on
Koha::Plugins::Base.
I had this result:
Test Summary Report:
t/00-valid-xml.t (Wstat: 1792 Tests: 381 Failed: 7)
Failed tests: 10, 30-31, 169, 181, 201-202
Non-zero exit status: 7
t/QueryParser.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
Files=92, Tests=12385, 45 wallclock secs ( 1.74 usr 0.15 sys + 26.61 cusr 1.92 csys = 30.42 CPU)
Result: FAIL
Failed 2/92 test programs. 7/12385 subtests failed.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
All tests pass, and I find no mention of the removed test code.
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>