Koha/t/db_dependent/Acquisition/OrderUsers.t
Julian Maurice b168f4a2e9 Bug 21395: Make perlcritic happy
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>
2020-06-29 12:37:02 +02:00

116 lines
3.4 KiB
Perl

use Modern::Perl;
use Test::More tests => 3;
use C4::Acquisition;
use C4::Biblio;
use C4::Letters;
use Koha::Database;
use Koha::Acquisition::Booksellers;
use Koha::Acquisition::Orders;
use Koha::Patrons;
use t::lib::TestBuilder;
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $library = $builder->build({
source => "Branch",
});
my $patron_category = $builder->build({ source => 'Category' });
my $currency = $builder->build({ source => 'Currency' });
# Creating some orders
my $bookseller = Koha::Acquisition::Bookseller->new(
{
name => "my vendor",
address1 => "bookseller's address",
phone => "0123456",
active => 1,
}
)->store;
my $basketno = NewBasket( $bookseller->id, 1 );
my $budgetid = C4::Budgets::AddBudget(
{
budget_code => "budget_code_test",
budget_name => "budget_name_test",
}
);
my $budget = C4::Budgets::GetBudget($budgetid);
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
my $order = Koha::Acquisition::Order->new(
{
basketno => $basketno,
quantity => 2,
biblionumber => $biblionumber,
budget_id => $budgetid,
entrydate => '2014-01-01',
currency => $currency->{currency},
orderstatus => 1,
quantityreceived => 0,
rrp => 10,
ecost => 10,
}
)->store;
my $ordernumber = $order->ordernumber;
my $invoiceid = AddInvoice(
invoicenumber => 'invoice',
booksellerid => $bookseller->id,
unknown => "unknown"
);
my $borrowernumber = Koha::Patron->new({
cardnumber => 'TESTCARD',
firstname => 'TESTFN',
surname => 'TESTSN',
categorycode => $patron_category->{categorycode},
branchcode => $library->{branchcode},
dateofbirth => '',
dateexpiry => '9999-12-31',
userid => 'TESTUSERID'
})->store->borrowernumber;
C4::Acquisition::ModOrderUsers( $ordernumber, $borrowernumber );
my $is_added = grep { /^$borrowernumber$/ } C4::Acquisition::GetOrderUsers( $ordernumber );
is( $is_added, 1, 'ModOrderUsers should link patrons to an order' );
$order = Koha::Acquisition::Orders->find( $ordernumber );
ModReceiveOrder(
{
biblionumber => $biblionumber,
order => $order->unblessed,
quantityreceived => 1,
cost => 10,
ecost => 10,
invoiceid => $invoiceid,
rrp => 10,
budget_id => $budgetid,
}
);
my $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
is( scalar( @$messages ), 0, 'The letter has not been sent to message queue on receiving the order, the order is not entire received');
$order = Koha::Acquisition::Orders->find( $ordernumber );
ModReceiveOrder(
{
biblionumber => $biblionumber,
order => $order->unblessed,
quantityreceived => 1,
cost => 10,
ecost => 10,
invoiceid => $invoiceid,
rrp => 10,
budget_id => $budgetid,
}
);
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
is( scalar( @$messages ), 1, 'The letter has been sent to message queue on receiving the order');