Commit graph

3203 commits

Author SHA1 Message Date
5b807fd3d7 Bug 20996: (follow-up) Fix test
- Fixes the t/db_dependent/Illrequest/Config.t
- Adds tests for Koha::Illrequest::Config->has_branch

0) Do not apply the path
1) Run test t/db_dependent/Illrequest/Config.t
2) It fails - it is because the Koha/Illrequest/Config.pm prefixes
handling changed
3) Apply the patch
4) Run test again, it should pass now
5) Read through the test code and confirm it makes sense

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-05 14:40:55 +00:00
Kyle M Hall
e87fa069dc Bug 20968: Rename method get_intranet_catalog_toolbar_button to intranet_catalog_biblio_enhancements_toolbar_button
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>
2018-11-02 10:36:03 +00:00
60ca17c616 Bug 20968: Add unit tests
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>
2018-11-02 10:36:03 +00:00
70651422a7 Bug 14385: (QA follow-up) Additional changes and fixes
[1] searchResults: second my $interface can be removed: unused
[2] call of getitemtypeimagelocation on L2119 needs interface key
[3] ISBDdetail: No need to find patron again (line 182 vs 84)
[4] opac-search: No need to find patron twice (657 and 631)
[5] tabs on line 2220 of C4/Search.pm (qa tools warn)
[6] Ugly hack to overcome "Undefined subroutine &C4::Items::ModZebra"
    by loading C4::Items before C4::Biblio when running tests
    Koha/BiblioUtils/Iterator.t and Labels/t_Label.t.
    This is a more general problem that needs attention somewhere else.
    It seems that Biblio.pm is one of the suspects.
[7] This patch set makes Search.t crash/fail with me. Note that without
    these patches Search.t still passed! Why o why..
    A little debugging pointed me to a missing MPL branch (aarg).
    Adding the simple test on the result of Libraries->find in
    C4::Biblio::GetAuthorisedValueDesc made the test continue.
[8] Resolve: Variable "$borcat" is not available at opac-detail.pl line 246
    Lexical $borcat cannot be used in sub searchAgain in opac-detail.pl
    under Plack. Must be defined with our (or passed as argument).
[9] Resolve crash on TWO serious typos in opac-basket on ONE line:
        Koha::Patron->find({ borrowernumber -> $borrowernumber })
    Yeah: find is in Koha::Patrons and we need => !!
    No need to pass a hash to find method btw for a pk value.
[10] Serious bugfixing here. Add List::Util to opac-basket.
    Can't locate object method "none" via package "1".
    You can't test everything :)

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
After this longer list I renamed Final to Additional in the patch title :)

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-02 10:33:12 +00:00
Mark Tompsett
e1b5fa657d Bug 14385: Squash of a lot of patches rebased
- Added missing GetHiddenItems parameter change case
     Without this prove t had a failure.

- Always use mocks, not set_preference

- Tweaks so t/db_dependent/00-strict.t passes
     There was a typo botcat vs borcat and borrowernumber was never
     defined. Grabbing from userenv, like other code does.

- Tweak t/db_dependent/Items.t to fully test changes
     This will test all the if structures fully in GetHiddenItemnumbers.
         prove t/db_dependent/Items.t

- Tweak borrower category code
     $borrower->{categorycode} on a Koha::Patron is not the
     same as $borrower->categorycode. Fixed error.

- Search was returning URLS for wrong interface
     There was one search context place wrong. Changed it to $is_opac
     as the logic for setting $is_opac was modified correctly.

- Corrected issues with category code.
     When a user isn't logged in, $borrower is undef and causes error
     when determining category code. Added conditional check.

- Properly trigger all changes in C4/Search.pm

- Fix QA Test tool failures
     C4/Search.pm had some tabs.

- Add some commenting to make sense of logic

- Refactor EmbedItemsInMarcBiblio parameters to hashref

- Trigger GetMarcBiblio's EmbedItemsInMarcBiblio call.
     prove t/db_dependent/Items.t

- Add missing test to trigger Koha/BiblioUtils/Iterator change

- Add borrower category overrides
     These files generally add borcat parameter to GetMarcBiblio.
     Others might include correction of filtering of items
     (opac-basket), or a comment as to why no changes were done
     (opac-search).

     In the case of opac-search, correcting the first FIXME will
     likely correct the OpacHiddenItems issues on tags. As such,
     that is beyond this bugs scope.

     Some code had loop optimizations and fixes made, like a
     'next unless $record' when the biblio shouldn't even be in
     the list.

- Modify opac-ISBDdetail and opac-MARCdetail
     Both files had similar logic. They were rearranged and
     optimized, so that both files would have practically identical
     initial blocks of code.

     Optimizations were possible, because GetMarcBiblio
     returns a filtered record, so that there is no double call
     (once in the opac-### file and once in GetMarcBiblio) to
     GetHiddenItemnumbers.

- Fix hiding in opac-tags
     opac/opac-tags.pl was not properly hiding.

     There is currently one known bug associated with tags left.
     If you have two biblios tagged by different people with the
     same tag, the opac-search will show the one you tagged that
     is supposed to be hidden, because tag searches work differently
     than regular searches. This is beyond the scope of this bug.
     See the FIXME's in opac/opac-search.pl

- Trigger the C4::ILSDI::Services changes
     prove t/db_dependent/ILSDI_Services.t

- Added missing 'my'

- Test C4/Labels/Label.pm changes

- Improve C4::Record::marcrecord2csv test cases

- Corrected opac-details searchResult call

- Fix breaking issues constraint in ITerator test

- Fix ILSDI_Services test when clubs with branch exist

- Rebased again!
- Rebased t/db_dependent/Items.t conflict.

The test plan is in comment #112 last I checked.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-02 10:33:12 +00:00
Chris Cormack
5e4e10c4ca Bug 14385: Extend OpacHiddenItems to allow specifying exempt borrower categories
Edit: Fixing merge conflicts in
 - t/db_dependent/Items.t
 - t/db_dependent/Search.t
 - C4/Search.pm

Changes the API for calling GetHiddenItems and all the places in the code that call it. This is to allow borrower categories to be passed in.
Adds an OpacHiddenItemsExceptions syspref to allow certain borrower categories to be able to see items, even if they are marked hidden by OpacHiddenItems

To test:

1) Make two borrowers, one in a category that should see everything (ie Adult), and another in a category that should only see certain things (ie Adult - exceptions)
2) Add the borrower that can see everything (the Adult) to OpacHiddenItemsExceptions
3) To the OpacHiddenItems syspref, add an item type (ensure that you have some records that fall under this type in your library).
4) Log in as the borrower that should only see certain things (Adult - exception)
5) Do a search, filtered to show records which are the item type that you specified in the OpacHiddenItems syspref. No records should show for this borrower as this item type is hidden to them.
6) Log in as the borrower that should see everything (Adult)
7) Do the same search. There should be results from this search, as this borrower category has been specified as an exception to the hidden items

Signed-off-by: Claire Gravely <c.gravely@arts.ac.uk>

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-02 10:33:09 +00:00
Andrew Isherwood
f4f995a4e6 Bug 20996: Fix unit tests
- Remove unit tests relating to TO_JSON
- Add tests for new explicit embedding
- Modify tests relating to now deprecated brw_cat

Signed-off-by: Magnus Enger <magnus@libriotech.no>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-02 10:33:03 +00:00
433fc3f120 Bug 21604: Add two trivial test cases
Adding an id in AddBudgetPeriod and an empty string in AddBudget for
budget_encumb.

Test plan:
Run Budgets.t with/without this patch in strict sql mode.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-02 10:33:01 +00:00
5e2b67d8c5 Bug 21717: Fix generation of real's values
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>
2018-11-01 19:05:46 +00:00
515ed462cf Bug 21556: Do not crash if a biblio is deleted twice
To recreate:
- Go to a bibliographic detail page
- Delete it
- Go back
- Delete it again
=> Without this patch you will get a 500
 Can't call method "holds" on an undefined value at
 /home/vagrant/kohaclone/C4/Biblio.pm line 406.
=> With this patch applied it will silently redirect you to the search
form.

Note: We could/should improve the behavior and display a message, but
DelBiblio will need to be moved to Koha::Biblio->delete and other
callers adjusted

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-01 19:05:12 +00:00
62613b6cf2 Bug 21681: Add tests for GetPatronInfo
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>
2018-10-31 13:52:08 +00:00
655caa61e6 Bug 21681: Remove C4::Accounts::getcharges
Test plan:
0) Do not apply the patch
1) Enable ILS-DI
2) Go to
<opac_url>/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=51&show_fines=1
use patron with some paid and unpaid fines
3) Save the page for later usage
4) Apply the patch
5) Repeat 2 with same patron and compare the saved result with the new
one, they should be same
6) git grep getcharges should return no occurance
7) prove t/db_dependent/Accounts.t

Co-authored-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>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:52:07 +00:00
00d5ceac1e Bug 21694: Add the Koha::Account->lines method
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:51:06 +00:00
77ea468639 Bug 18720: Use exception instead of die in GetBasketAsCsv
Test plan:
prove t/db_dependent/Acquisition/GetBasketAsCSV.t

Signed-off-by: Andrew Isherwood <andrew.isherwood@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:47:17 +00:00
aced7b10de Bug 20941: (QA follow-up) Fix return value of get_type, make templates more consistant
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:45:56 +00:00
Andrew Isherwood
7cecc27e01 Bug 20941: (follow-up) Carry out comment #4 advice
- Switch getType -> get_type
- get_type now returns a type or undef
- Ternary now performed in template

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:45:55 +00:00
Andrew Isherwood
676fbe12ea Bug 20941: Add unit tests
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:45:55 +00:00
da2a8c7b18 Bug 21581: Unit tests and updated data
To test:
1 - Apply this patch only
2 - prove -v t/db_dependent/Search.t
3 - It fails
4 - Apply second patch
5 - prove -v t/db_dependent/Search.t
6 - It passes!

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:17:47 +00:00
3db4926db3 Bug 13098: Do not compare with precision
Formating will be done TT side

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:13:38 +00:00
0fb422d8f9 Bug 13098: Tests for all _FixAccountForLostAndReturned use cases
This patch introduces tests for all the use cases for
_FixAccountForLostAndReturned. This includes the following scenarios
before _FixAccountForLostAndReturned is called:

- Full write off (the original issue)
- Full payment
- No payment or write off
- Partial payment and partial write off

Written off debts (L lines) are just skipped, any kind of payment is
added and then refund as a single credit (CR). Amount outstanding is set
to 0. Offsets need to be generated for paper trail of this decisions.

To test:
- Run:
  $ kshell
 k$ prove t/db_dependent/Circulation.t
=> FAIL: Tests fail because _FixAccountForLostAndReturned is not doing
the right thing :-D

Followed test plan, patch works as described
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:12:25 +00:00
9acfe17257 Bug 13098: Add Koha::Account::Offsets->total
This patch introduces this trivial method for returning the sum0 result
of the amount columns of a Koha::Account::Offsets set.

To test:
- Apply this patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/Account/Offsets.t
- Sign off :-D

Followed test plan, patch worked as described
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-31 13:12:25 +00:00
5a979fd0c4 Bug 21613: Add a test
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-29 00:40:52 +00:00
Magnus Enger
2460eb0597 Bug 18591: Allow any number of comments on ILLs
This patch makes it possible to add arbitrary comments to ILL
requests. Comments are read only and displayed in chronological
order. Comments can be added by librarians, but also added automatically
based on comments in the different protocols, so that comments from the
lending library can also be added.

To test:
- Enable the ILL module ("ILLModule" syspref + config in koha-conf.xml)
- Install the Dummy backend from here:
  https://github.com/PTFS-Europe/Dummy
- Create a Dummy ILL request
- Add comments to the request, checking that the name and borrowernumber
  of the person that added the comment is displayed ok
- Check that the displayed date and time the comment was submitted follows
  the "dateformat" syspref
- On the "List requests" page, check that the correct number of comments
  is displayed in the "Comments" column
- Check that the tests pass:
  prove t/db_dependent/Illcomments.t

Signed-off-by: andrew.isherwood@ptfs-europe.com

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-27 13:15:58 +00:00
ddef9376f2 Bug 21576: Preserve chomp chars for USE raw
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>
2018-10-26 17:09:53 +00:00
1dbea5dd2c Bug 21576: Handle complex uri
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>
2018-10-26 17:09:52 +00:00
2e92525848 Bug 21576: Keep compatibility with QA script
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>
2018-10-26 17:09:52 +00:00
c933244fe6 Bug 21576: Add a developer script to fix missing TT filters
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>
2018-10-26 17:09:51 +00:00
41397c8553 Bug 21603: Remove incorrect GROUP BY from C4::CourseReserves
'koha_kohadev.c.department' isn't in GROUP BY

Test plan:
Prove that the test fail without this patch and pass with this patch
applied (switch on the SQL modes)

Signed-off-by: Andrew Isherwood <andrew.isherwood@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-26 16:33:14 +00:00
8ae6242d08 Bug 21337: (QA follow-up) Rename exception code
Patron::Delete becomes Patron::FailedDelete.
Trivial replace.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-26 16:06:57 +00:00
91d168200e Bug 13618: Remove html filter for LAST
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-26 15:54:55 +00:00
1ce984ea1d Bug 15486: Fix failing test in GetHardDueDate.t
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-25 12:36:59 +00:00
a7c3ba0436 Bug 15766: Update tests
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-25 12:34:40 +00:00
dad1324b1b Bug 15486: Unit tests
This patch introduces unit tests for the new circulation rules option
that allows setting a max holds per day limit.

To test:
- Apply the patch
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/db_dependent/Holds.t
=> FAIL: CanItemBeReserved doesn't check the amount of holds per day
   and the introduced error code is not returned. OK is returned
   instead.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-24 13:24:04 +00:00
df91e14135 Bug 21607: Make Koha::Account::Line->apply store credits as negative amounts
This is a trivial patch, that makes offsets have 'amount' stored as
negative values for applied credits.

The behaviour is changed on the tests and adjusted in the code. To test:
- Run
  $ kshell
 k$ prove t/db_dependent/Koha/Account/Lines.t
=> SUCCESS: Tests pass!
- Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-19 17:27:43 +00:00
619eca1c7a Bug 20592: Add tests
NOTE: It isn't really a test, but it does trigger
      the return line which was added to ModItem.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-19 17:27:36 +00:00
b7da4f890b Bug 21597: Incorrect decimal value: 't_value_bib639' for column 'price'
Fix t/db_dependent/selenium/basic_workflow.t

We want to send specific values depending on the data type in DB
For instance integer, or varchar(10)

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-18 14:18:01 +00:00
573d9dafc1 Bug 21597: Field 'description' doesn't have a default value
Nick proposed another fix, see bug 21594.
The interface does not explode so I do not think we should make a DB
update in a rush.

Fix t/db_dependent/Koha/Object.t and t/db_dependent/Koha/ApiKeys.t

api_keys.description and api_keys.secret:
  `secret` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,

    #   Failed test 'Exception is thrown correctly'
    #   at t/db_dependent/Koha/Object.t line 262.
    # expecting: Koha::Exceptions::Object::FKConstraint
    # found: DBIx::Class::Exception (DBIx::Class::Storage::DBI::_dbh_execute(): Field 'description' doesn't have a default value at /home/vagrant/kohaclone/Koha/Object.pm line 125
    # )
    # Looks like you planned 7 tests but ran 1.
    # Looks like you failed 1 test of 1 run.

and later, but not related:
Can't locate object method "message" via package
"DBIx::Class::Exception" at t/db_dependent/Koha/Object.t line 264.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-18 14:18:00 +00:00
489c636316 Bug 21597: Incorrect date value: '0' for column 'onloan'
Fix t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t

items.onloan
  `onloan` date DEFAULT NULL,

DBIx::Class::Storage::DBI::_dbh_execute(): Incorrect date value: '0' for
column 'onloan' at row 1 at /home/vagrant/kohaclone/t/lib/TestBuilder.pm
line 288

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-18 14:18:00 +00:00
f19a992095 Bug 21597: Data too long for column 'invitekey'
Fix t/db_dependent/Virtualshelves.t

virtualshelfshares.invitekey
  `invitekey` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,

We should not insert a longer string!

DBIx::Class::Storage::DBI::_dbh_execute(): Data too long for column
'invitekey' at row 1 at /home/vagrant/kohaclone/Koha/Object.pm line 125

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-18 14:18:00 +00:00
82884b0bd8 Bug 21597: Field 'amount' doesn't have a default value
Fix t/db_dependent/Accounts.t

Default value could be 0, or left as it.
It seems that the different initialisation we have in the code pass a
value for 'amount'

account_offsets.amount
  `amount` decimal(26,6) NOT NULL,

DBIx::Class::Storage::DBI::_dbh_execute(): Field 'amount' doesn't
have a default value at /home/vagrant/kohaclone/Koha/Object.pm line 125

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-18 14:17:59 +00:00
a40b8ebde7 Bug 21597: Column 'notforloan' cannot be null
Fix t/db_dependent/Circulation.t

items.notforloan:
  `notforloan` tinyint(1) NOT NULL DEFAULT '0',

t/db_dependent/Circulation.t .. 115/119 DBD::mysql::st execute failed: Column 'notforloan' cannot be null [for Statement "UPDATE `items` SET `notforloan` = ? WHERE ( `itemnumber` = ? )" with ParamValues: 0=undef, 1='1046'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.
        # No tests run!

    #   Failed test 'No tests run for subtest "item-level_itypes = 0"'
    #   at t/db_dependent/Circulation.t line 2356.
    # Looks like you failed 1 test of 2.

 #   Failed test 'CanBookBeIssued | notforloan'
 #   at t/db_dependent/Circulation.t line 2359.
Can't locate object method "rethrow" via package "DBD::mysql::st execute failed: Column 'notforloan' cannot be null [for Statement "UPDATE `items` SET `notforloan` = ? WHERE ( `itemnumber` = ? )" with ParamValues: 0=undef, 1='1046'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-18 14:17:59 +00:00
4e6d9defc1 Bug 21155: Prevent SwitchOnSiteCheckouts.t to fail randomly
#   Failed test 'The date_due should have been set depending on the circ
 rules when the on-site checkout has been switched'
 #   at t/db_dependent/Circulation/SwitchOnSiteCheckouts.t line 126.
 #          got: '2018-10-16T23:59:00'
 #     expected: '2018-10-21T23:59:00'

TestBuilder set date to today, so issuingrules.harduedate will be set to
today.
issuingrules.hardduedatecompare will be set to an integer.
If set to 0, $datedue will be reset to the hard due date

The call stack is: AddIssue > CalcDateDue > GetHardDueDate

In GetHardDueDate:
3509         if ( $hardduedatecompare == 0 || $hardduedatecompare == $cmp ) {
3510             $datedue = $hardduedate->clone;
3511         }

To fix this random failure we need to set issuingrules.harduedate to undef.

Test plan:
0. Do not apply this patch
1. Modify the test to set hardduedatecompare to 0 (search 'my $issuingrule = ')
2. Execute the test and confirm the failure
3. Apply this patch
4. Execute the test and confirm the it is no longer failing

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-17 12:28:13 +00:00
dc6bea7860 Bug 21479: "Mock" SearchEngine to use Zebra
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-16 12:41:42 +00:00
82ff8138b4 Bug 21337: Koha::Objects->delete must return the number of deleted rows
To follow DBIC behaviour

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-15 17:53:15 +00:00
e7574481b1 Bug 21479: Zebra index can return different result
If the zebra index has been rebuilt by previous tests, the order/results
will be different, and we will not have biblionumber 1, 3, 5

Let make this more flexible

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-15 16:46:34 +00:00
5e2862c6b8 Bug 21337: (RM follow-up) Adjust number of tests
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-15 14:14:47 +00:00
936198ba6a Bug 21337: (QA follow-up) Rollback for partial delete
Puts delete loop in a txn_do.
Raises Koha::Exceptions::Patron::Delete when Patron->delete does not return
true (like 0 or -1).
Unit test adjusted accordingly.

Note: A follow-up report for raising exceptions in Object->delete could well
be considered. Not here please.

Test plan:
Run t/db_dependent/Koha/Patrons.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-15 14:12:55 +00:00
720d6360a0 Bug 21337: (follow-up) Add parameter for move_to_deleted action
For consistency, it would be better to make the move optional.

Test plan:
Run again t/db_dependent/Koha/Patrons.t.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-15 14:12:54 +00:00
e652f47ced Bug 21337: Add Koha::Patrons->delete (trivial wrapper)
Adds Koha::Patrons->delete as wrapper around Koha::Patron->delete. We do
not want to bypass Koha::Patron and let DBIx do the job without further
housekeeping. A call to move_to_deleted is included now, but could be
made optional with a parameter if needed.

Test plan:
Run t/db_dependent/Koha/Patrons.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-15 14:12:54 +00:00
Alex Arnaud
9c6025ccbf Bug 10382: Course reserves: handle empty values
Test Plan:
1) Create an item, do not set a collection code
2) Add the item to a course, and choose to set a collection code
3) Ensure the course is enabled, and the collection code is now visible
4) Disable the course, ensure the collection code is no longer visible

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-15 12:44:50 +00:00