#!/usr/bin/perl
use Modern::Perl;
-use Test::More tests => 37;
+use Test::More tests => 40;
use C4::Context;
use Koha::AdditionalField;
+use Koha::Database;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
$dbh->do( q|DELETE FROM additional_fields| );
$dbh->do( q|DELETE FROM additional_field_values| );
use C4::Serials::Frequency;
use C4::Serials::Numberpattern;
-my $booksellerid = C4::Bookseller::AddBookseller(
- {
- name => "my vendor",
- address1 => "bookseller's address",
- phone => "0123456",
- active => 1
- }
-);
-
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
my $budgetid;
my $bpid = AddBudgetPeriod({
- budget_period_startdate => '01-01-2015',
- budget_period_enddate => '01-01-2016',
- budget_description => "budget desc"
+ budget_period_startdate => '2015-01-01',
+ budget_period_enddate => '2016-01-01',
});
my $budget_id = AddBudget({
budget_amount => "123.132",
budget_name => "Périodiques",
budget_notes => "This is a note",
- budget_description => "Serials",
- budget_active => 1,
budget_period_id => $bpid
});
my $frequency_id = AddSubscriptionFrequency({ description => "Test frequency 1" });
my $pattern_id = AddSubscriptionNumberpattern({
label => 'Test numberpattern 1',
+ description => 'Description for numberpattern 1',
numberingmethod => '{X}'
});
$exists = grep /not_existent_id/, @$matching_record_ids;
is ( $exists, 0, "get_matching_record_ids: field common: common% does not inexistent id" );
+# delete_values
+$af1 = Koha::AdditionalField->new({ id => $af1->id })->fetch;
-$dbh->rollback;
+$af1->fetch_values;
+is_deeply ( $af1->values, {$subscriptionid1 => qq|value_for_af1_$subscriptionid1|, $subscriptionid2 => qq|value_for_af1_$subscriptionid2| }, "fetch_values: without argument, returns 2 records" );
+$af1->delete_values({record_id => $subscriptionid1});
+$af1->fetch_values;
+is_deeply ( $af1->values, {$subscriptionid2 => qq|value_for_af1_$subscriptionid2|}, "fetch_values: values for af2 and subscription2" );
+$af1->delete_values;
+$af1->fetch_values;
+is_deeply ( $af1->values, {}, "fetch_values: no values" );