4 use Test::More tests => 5;
8 use C4::Biblio qw( AddBiblio );
10 use_ok('C4::Serials');
11 use_ok('C4::Budgets');
13 my $dbh = C4::Context->dbh;
14 $dbh->{AutoCommit} = 0;
15 $dbh->{RaiseError} = 1;
18 my $supplierlist=eval{GetSuppliersWithLateIssues()};
19 ok(length($@)==0,"No SQL problem in GetSuppliersWithLateIssues");
21 my $record = MARC::Record->new();
22 $record->append_fields(
23 MARC::Field->new( '952', '0', '0', a => 'CPL', b => 'CPL' )
25 my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, '');
28 my $bpid = AddBudgetPeriod({
29 budget_period_startdate => '01-01-2015',
30 budget_period_enddate => '12-31-2015',
31 budget_description => "budget desc"
34 my $budget_id = AddBudget({
35 budget_code => "ABCD",
36 budget_amount => "123.132",
37 budget_name => "Périodiques",
38 budget_notes => "This is a note",
39 budget_description => "Serials",
41 budget_period_id => $bpid
44 my $subscriptionid = NewSubscription(
45 undef, "", undef, undef, $budget_id, $biblionumber,
46 '2013-01-01', undef, undef, undef, undef,
47 undef, undef, undef, undef, undef, undef,
48 1, "notes",undef, '2013-01-01', undef, undef,
49 undef, undef, 0, "intnotes", 0,
50 undef, undef, 0, undef, '2013-12-31', 0
52 die unless $subscriptionid;
55 my $subscription = GetSubscription( $subscriptionid );
56 is( C4::Serials::can_edit_subscription($subscription), 0, "cannot edit a subscription without userenv set");
69 C4::Context->_new_userenv ('DUMMY_SESSION_ID');
70 C4::Context->set_userenv ( @USERENV );
72 # Can edit a subscription
73 my $userenv = C4::Context->userenv;
75 is( C4::Serials::can_edit_subscription($subscription), 1, "User can edit a subscription with an empty branchcode");
76 #TODO add UT when C4::Auth->set_permissions (or setuserflags) will exist.