batches, it is now possible to 'clean' a batch by
removing all bib and item records staged in the batch. This
has the effect of helping to reduce database space used
by old import batches as well as removing staged records
from the cataloging reservoir search. Note that 'cleaning'
a batch affects only the copies of the records that were staged;
if the batch was committed, cleaning the batch does not
affect any bibs and items that were committed into the catalog.
Also note that once you clean a committed batch of records, it is
impossible to undo the previous commit operation.
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
Required for SIP checkin implementation, but also for internal correctness.
AddReturn had too many things going on, with no guarantee of data being
available for the later calls. At some point we started tacking on all the
branch transfer logic without testing edge cases. In particular, $borrower
is not checked to be sure it is defined, considering the item may not have been
checked out so no borrower would be associated. That means that CircControl
of "PatronLibrary" would be inaccurate, Circ Alerts will be totally confused
(untargeted), and the Fix... subs would fail.
Note that *many* errors are still present in _FixAccountForLostAndReturned, including
those where comments are added, such that it might behave strangely even with $borrower.
Renamed the internal subs with leading underscore, per convention. Changed
the arguments to be scalars when only scalars are needed, not entire objects.
Added depth to WrongBranch message that includes Rightbranch.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
The following functions are no longer in use:
* old_newsubscription
* old_modsubscription
* old_getserials
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
The distributedto column of the subscription table is
no longer used, having been replaced by the serials
routing list table. This patch removes two C4::Serials
functions and a script and template, none of which were
reachable by current code:
C4::Serials::GetDistributedTo()
C4::Serials::SetDistributedTo()
koha-tmpl/intranet-tmpl/prog/en/modules/serials/distributedto.tmpl
serials/distributedto.pl
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Removed routines in C4/NewsChannels.pm that refered
to missing database tables news_channels and news_channel_categories.
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Removed routines in C4/NewsChannels.pm that refer to
a missing opac_electronic table.
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Removed opac/opac-dictionary.pl and catalogue/dictionary.pl,
which were not in use and not linked to from any active
template files. According to Henri, the functionality that
these scripts implemented hasn't been working since 2.2.
Also removed C4::Search::findseealso(), which was used
only by the two scripts.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Per discussion I had with Henri, removing experimental
bulk editing from the staff search results code, as
feature is incomplete and can be dangerous if
one tries to use it on a large search result
set.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
I added 'use warnings' to C4::Biblio and made a handful of changes to
reduce the number of warnings emitted.
One notable spot is the change in the regex in
C4::Biblio::GetNoZebraIndexes. I have replaced the parens with a character
class. The parens change the way 'split' works, making it return elements
for each delimiter. We did not want those elements returned, and they
only resulted in "'' => undef" being added to the final hash. They also
resulted in two "undefined" warnings for each pass through the loop. I've
included a simple test for this function.
There may be a few warnings still emitted in spots, but either I haven't
seen them yet, or I have chosen to not fix them yet because they require
too much change.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Tests for C4::Members::GetMemberDetails. Validates both calls
using either borrowernumber or cardnumber.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Tests the functionality of C4::Members::GetMember. Tests exist
for every way that GetMember could be called on to search for an
existing member.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This patch adds two warning messages to places in the test suite that
may fail. I don't think it changes any functionality, but it sure makes
it easier to figure out what has gone wrong.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Fixes problem where if the IssuingInProcess preference is ON,
the operator is always required to confirm a checkout if
the patron has had any fine transactions at all, even if
the patron's balance is 0.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Changed so that issues.issuedate is never modified
during a renewal, since that column records the original
date of the loan. Changed the name and interpretation
of the $issuedate parameter of AddRenewal() to
$lastreneweddate, allowing (e.g.) offline circulation
to set the date of the renewal without changing the
issue date.
As a result of the original bug, issues.issuedate can be
set to NULL for loans that were renewed via the OPAC,
self checkout, or the staff interface when explicitly
renewing a loan. Loans that were renewed by checking
the item out to the same patron will have the issue date
changed to the date of the last renewal.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
CalcFine returned values that mismatched expectations in fines.pl.
fines.pl refactored: added debugging, prevent needless recreation of
Calendar objects by storing them in hash by branch.
Still outstanding problems with fines, including the output of a field
that has no other references in Koha (so is always undef) and the
incorrect description of FinesMode.
Calendar exported "new" erroneously. I also cleaned up the queries to
avoid needlessly compiling additional statement handles.
Please test and consider application to 3.0 maintenance.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
I'm adding some tests for C4::Circulation methods that I'm altering
to allow the offline circulation tool to use C4::Circulation to upload
its data. These test a bit of the old functionality and try to show
that the new functionality does what I think it does.
C4::Circ::Addissue to tests issuedate
these also test AddRenewal.
tests for C4::Circ::MarkIssueReturned
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This patch fixes the tests so that they include the new required parameters for longoverdues.pl.
This patch also doesn't include a test script that accidently got in the last one.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
The tests I wrote for C4::Items::GetItemsForInventory confused the differences
between biblionumber and itemnumber. That wasn't uncovered on my limited test
database, but I uncovered it later.
This fixes that problem by populating a $self->{'items'} list with details of any items
added by KohaTest::add_biblios. Then, tests can probe there for the details of items
they should expect to find when searching.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This test suite tests the several different ways that we can call C4::Koha::displayServers.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4::Koha::get_itemtypeinfos_of was not using plceholders, opening itself up to
potential SQL injection attacks. This patch refactors it to use placeholders to
bind parameters.
I also had to extend C4::koha::get_infos_of to allow us to pass bind parameters into it.
I'm including a test module for C4::Koha::get_itemtypeinfos_of.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
The SQL in C4::Items::GetItemsForInventory wasn't using placeholders and
bind parameters, possibly leaving itself open ot SQL injection attacks. This
patch changes that.
I've also incliuded a test module for C4::items::GetItemsForInventory.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Here are a few improvments to the test suite to make it easier to write some tests
for C4::Items
I extracted "tomorrow" and "yesterday" methods from a test module into the base class
so that they could be used by multiple test modules
Adding callnumber to items added in the test suite.
I recatored KohaTest::add_biblios a bit to remove the manual count of the number of
MARC::Fields that were added.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
&NewOrder did not save the branchcode posted with a new order. This patch adds that param.
Added code to select the branch the order is for in the branch dropdown list on
acqui/orderreceive.pl
Updating POD and tests
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4::Context->preference was not using placeholders and was potentially vulnerable to
a SQL injectin attack. This patch refactors the method to use placeholders.
Added some tests for C4::Context.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
patch to C4::Members::ModMember to prevent it from deleting the dateofbirth field when none is supplied.
I also added a KohaTest::random_date method to help generate randomish dates for the test suite.
Added some tests for Member::ModMember. This is an easy method to test, and this bug shows that it
could use some closer examiniation.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This patch adds the misc/cronjobs/overdue_notices.pl script that is intended to replace
overduenotices.pl, overduenotices-30.pl and overduenotices-csv.pl. It adds messages to
the message_queue to be sent later (by process_message_queue.pl). It also marks borrowers
as debarred if their issues become too overdue.
It is intended to be run from cron nightly with usage something like:
0 2 * * * misc/cronjobs/overdue_notices.pl
C4::Members:
- improved documentation on ModMember
- made ModMember return a useful value (the return value of the database call)
- added a DebarMember method
- adding t/lib/KohaTest/Members/DebarMember.pm to test ModMember
misc/cronjobs/overdue_notices.pl
- designed to replace overduenotices.pl, overduenotices-30.pl, and overduenotice-csv
Changes to C4::Letters:
- EnqueueLetter now lets you pass in to_address and from_address which can override defaults
- _send_message_by_email pays attention to these defaults.
- now handles attachments with MIME::Lite
C4::Overdues
- added GetBranchcodesWithOverdueRules
- added t/lib/KohaTest/Overdues/GerBranchcodesWithOverdueRules.pm to test that.
circ/overdue.pl
- replaced call to obsolete overduenotices-csv.pl with call to overdue_notices.pl
KohaTest:
- added three helper methods: random_phone, random_email, random_ip
- these can be used to populate example records
- you can now pass an optional lengh to random_string
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
When generating the display form of a heading that
happens to (invalidly) have a regular expression
metacharacter as a subfield label, do not crash.
An example of such a heading field is:
<datafield tag="650" ind1=" " ind2="0">
<subfield code="a">Dalziel, Andrew (Fictitious character</subfield>
<subfield code=")">xFiction.</subfield>
</datafield>
The error message associated with the crash is:
Unmatched ) in regex; marked by <-- HERE in m/) <-- HERE / at
/home/koha-pro/kohaclone/C4/Heading/MARC21.pm line 220.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
It was observed that the %thash and @formats variables
were not being properly initalized during a make single-test run.
To ensure initialization, created startup and shutdown
methods to initialize those values as part of the
test object.
I have not yet investigated why the original way of
setting up %thash and @formats did not work.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
t/Labels.t was dependent on a working test database, so I'm moving those
tests into t/lib/KohaTest
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
The t/Items.t tests were actually dependent on the database, so I'm moving them
into t/lib/KohaTest.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
the t/Dates.t tests were actually databasase dependent. This patch replaces
t/Dates.t with t/lib/KohaTest/Dates/Usage.pm that relies on a database.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
I wrapped the use of the SMS::Send module in an eval to make failures graceful if it
is not present.
I also fixed an error with the number of tests in the SMS::Send tests.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Added support for a new target in the test Makefile
to run a single test module. If you do (for example)
make test-single TEST_FILES=lib/KohaTest/Biblio.pm
only the tests in that module will be run. Unlike
the full test suite as run via 'make test', 'make test-single'
does not clear the test database before running the
tests.
Please note that "TEST_FILES=path/to/test/class.pm" is
required when using 'make test-single'.
Signed-off-by: Andrew Moore <andrew.moore@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Prior to this patch, ModBiblio() would append
item tags from the previous version of the bib record
to the incoming bib record before saving the results,
even if the incoming bib record already has embedded
item tags.
For example, if a bib is retrieved using GetMarcBiblio() then
saved using ModBiblio(), the caller was obliged
to delete any item tags first to avoid duplication.
ModBiblio() now deletes item tags supplied in the
incoming MARC record. This eliminates the possibility
of duplication, and removes any implication that
ModBiblio() can or should be used to modify item
records - ModItem() should be used for that.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
The add_biblios() routine now reindexes all bibs
in batch instead of waiting for zebraqueue_daemon - this
is moderately faster. A separate set of test
cases for zebraqueue_deamon will be witten.
No documentation changes.
Signed-off-by: Andrew Moore <andrew.moore@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Test cases in KohaTest/Search/SimpleSearch.pm assumed
that they were the first to call add_biblios(); as
this is not necessarily true when the entire test
suite is run, test now counts how many 'Finn Test'
bibs already exist.
No documentation changes.
Signed-off-by: Andrew Moore <andrew.moore@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
I changed getitemtypeimagedir to set a default on its argument so that it would not complain if not passed 'opac'.
I improved the documentation on the method.
I edited the t/icondirecotries.t test script to explicitly pass an argument to both getitemtypeimagedir calls.
- and I adjusted one line of whitespace to make similar things look similar
I added a test module for C4::Koha
I added a test module for C4::Koha::getitemtypeimagedir.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
I've added methods to to C4::Letters to manage the database table
message_queue. This will let us keep track of messages sent
via email, sms, and rss to patrons. That way, we can show the history,
deal with failures, and reconstruct an RSS feed when needed.
misc/cronjobs/overduenotics.pl has been added. It prepares advance notices
and item due notices and stages messages to be sent in the message_queue
table.
C4::Overdues::Getoverdues now takes two optional arguments to tell it how
old of overdues to fetch.
Also, a C4::Circualtion::getUpcomingDueIssues method was added that
advance_notices.pl uses.
misc/cronjobs/process_message_queue.pl has been added. It sends the email
or SMS messages out of the message queue.
The C4::SMS module didn't work at all, and it has been rebuilt to use
an external perl module from CPAN, SMS::Send.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This routine retrieves the branch/patron category circulation
rules for a given branch and patron category. The return
value is a hashref containing the following key:
maxissueqty - maximum number of loans across all item types
This will first check for a specific branch and
category match from branch_borrower_circ_rules.
If no rule is found, it will then check default_branch_circ_rules
(same branch, default category). If no rule is found,
it will then check default_borrower_circ_rules (default
branch, same category), then failing that, default_circ_rules
(default branch, default category).
If no rule has been found in the database, it will default to
the built in rule:
maxissueqty - undef
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
You can test getnextacctno like:
perl -e 'use C4::Accounts; print getnextacctno(33), "\n";'
where 33 is a borrowernumber out of the accountlines table. Get that number like:
mysql> select borrowernumber,accountno from accountlines LIMIT 100;
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
I had these tests laying around for a while. I just forgot to commit them.
No functional or documentation changes needed.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Defined a function attribute for KohaTest and subclasses
called 'Expensive'. When a test method has that attribute,
it is skipped unless the RUN_EXPENSIVE_TESTS environment
variable is true.
To mark a test method, expensive, do this:
sub test_foo : Tests(4) Expensive { ... }
To mark a whole class and its subclasses expensive,
define a SKIP_CLASS sub (with empty body) with the
Expensive attribute:
sub SKIP_CLASS : Expensive { }
Updated the t/Makefile so that 'make test' runs
nonexpensive tests, while 'make fulltest' runs both
cheap and expensive tests.
Marked KohaTest::Installer test class expensive.
Signed-off-by: Andrew Moore <andrew.moore@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Corrected bug that prevented the 'not' operator
from working consistently - i.e., a search of
'mice not men' would not always work.
Also added test cases for NoZebra, so far focusing on
NZanalyse and adding and deleting bibs. A couple of
the test cases are currently known to fail and
therefore are marked TODO. The tests in question
are to verify that rows in nozebra are removed if
no bib is linked to the relevant word. However, it
looks like such rows are retained, just with
nozebra.biblionubmers set to ''. Is there any
reason to keep these rows?
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
In the course of writing tests for C4::Calendar, I found two bugs and am fixing them here.
One is a documentation bug.
The other prevented C4::Calendar::insert_exception_holiday from working. I was unable
to find anywhere else in the code that depended on the broken behaviour.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
I moved C4::Branch::GetBranches to use bind parameters and wrote some tests to demonstrate functionality.
No functional or documentation changes here.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Now handles cases where two SQL scripts in different
directories have the same name, e.g., fr-FR sample_itemtypes.sql.
Bug was masked by existing failure when attempting to load
both sample_itemtypes.sql.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Two new modules to support patron attributes:
- C4::Members::AttributeTypes
OO-module for managing patron attribute types.
- C4::Members::Attributes
Procedural module for retrieving and setting
extended attributes belonging to a patron.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Added tests of loading the DB initialization and
sampple data SQL scripts for every language
and MARC flavour combination defined in
installer/data/{dbms}. Errors that the
new test class should catch include:
* SQL syntax errors in kohastructure.sql
* SQL errors in the sample data
For each language and MARC flavour combination,
all mandatory and optional scripts are loaded.
As of this commit, several errors are reported
by this test class; these will be fixed separately.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Moved routines to clear and create database and manage
zebraqueue_daemon.pl to KohaTest.pm so that they're
available to test classes - needed for installation
and upgrade tests in particular.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Some minor changes to get the test suite working a bit better:
I removed a superfluous method from t/lib/KohaTest.pm.
I made each barcode for the items added in KohaTest.pm unique so that they would actually get inserted.
Then, I removed t/override_context_prefs.pm. If you need that functionality, you're a database
dependent test and should be a module in t/lib.
So, I deleted all of the trivial .t tests that just 'use'd their modules and had no other
tests and replaced them with lib/KohaTest/*pm modules that do a little bit more checking
on those modules.
I removed the references to override_context_prefs.pm in all of the other .t modules.
They all pass now with no override_context_prefs.pm module.
The database_depenedent.pl test script still does not pass entirely. There's a problem with the zebra index
not being reset each time that the tables are truncated. I'll get to that.
no functional or documentation changes here.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
I'm adding some functional tests that demonstrate that long_overdue.pl does what we think it does.
These tests don't actually work since override_context_prefs.pm gets in the way of C4::Context::preference. I opened up bug 2088 to address that.
There are no functional or documentation changes due to this patch.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Removed the categorytable, mediatypetable, and subcategorytable
tables. These three tables appear to be from an incomplete
patch from pre-git that defined these tables to implement
additional search limits, and are not present in the 2.2.9
package. In 3.0, these tables did nothing - the only code that
referred to them are incomplete admin editors that lack HTML
templates and are not referred to anywhere.
The updatedatabase.pl logic to remove these tables is conservative;
the tables are dropped only if they exist and are all empty. Effectively,
this means that they'll be dropped if you've been running a fresh install
of 3.0 from git or the alphas or betas; if you've upgraded your database
from 2.2.9, these tables likely weren't in your database to begin with.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
Enhanced the ability of catalogers to specify how
bib and item records should be added, replaced, or
ignored during a staging import.
When an import batch of bib records is staged and commit,
the user can now explicitly specify what should occur
when an incoming bib record has, or does not have, a match
with a record already in the database. The options are:
if match found (overlay_action):
create_new (just add the incoming record)
replace (replace the matched record with the incoming one)
use_template (option not implemented)
ignore (do nothing with the incoming bib; however, the
items attached to it may still be processed
based on the item action)
if no match is found (nomatch_action):
create_new (just add the incoming record)
ignore (do nothing with the incoming bib; in this
case, any items attached to it will be
ignored since there will be nothing to
attach them to)
The following options for handling items embedded in the
bib record are now available:
always_add (add the items to the new or replaced bib)
add_only_if_match (add the items only if the incoming bib
matches an existing bib)
add_only_if_add (add the items only if the incoming bib
does *not* match an existing bib)
ignore (ignore the items entirely)
With these changes, it is now possible to support the following use cases:
[1] A library joining an existing Koha database wishes to add their
items to existing bib records if they match, but does not want
to overlay the bib records themselves.
[2] A library wants to load a file of records, but only handle
the new ones, not ones that are already in the database.
[3] A library wants to load a file of records, but only
handle the ones that match existing records (e.g., if
the records are coming back from an authority control vendor).
Documentation changes:
* See description above; also, screenshots of the 'stage MARC records
for import' and 'manage staged MARC records' should be updated.
Test cases:
* Added test cases to exercise staging and committing import batches.
UI changes:
* The pages for staging and managing import batches now have
controls for setting the overlay action, action if no match,
and item action separately.
* in the manage import batch tool, user is notified when they
change overlay action, no-match action, and item action
* HTML for manage import batch tool now uses fieldsets
Database changes (DB rev 076):
* added import_batches.item_action
* added import_batches.nomatch_action
* added 'ignore' as a valid value for import_batches.overlay_action
* added 'ignored' as a valid value for import_records.status
* added 'status' as a valid value for import_items.status
API changes:
* new accessor routines for C4::ImportBatch
GetImportBatchNoMatchAction
SetImportBatchNoMatchAction
GetImportBatchItemAction
SetImportBatchItemAction
* new internal functions for C4::ImportBatch to
determine how a given bib and item are to be
processed, based on overlay_action, nomatch_action,
and item_action:
_get_commit_action
_get_revert_action
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
KohaTest->reindex_marc() does a full Zebra reindexing of
bib and authority records and clears zebraqueue. It is
meant for use in test classes that do a lot of bib, authority,
and/or item record changes that would be slowed down by
waiting for zebraqueue_daemon.
Also adjusted list of tables that are automatically truncated.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
I'm adding some more warnings in Makefile.PL to indicate that you WILL lose the data
in your testing database.
I've also relaxed the requirement that the teting database have "test" in its name.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This patch makes the test suite work even when $PERL5LIB isn't set to the install directory.
It replaces $PERL5LIB with '..' in order to help ensure that we're loading the C4 libraries
out of the installation directory.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
These test libs should have been included in the previous patch.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>