|
Lines 3-26
Link Here
|
| 3 |
# This Koha test module is a stub! |
3 |
# This Koha test module is a stub! |
| 4 |
# Add more tests here!!! |
4 |
# Add more tests here!!! |
| 5 |
|
5 |
|
| 6 |
use strict; |
6 |
use Modern::Perl; |
| 7 |
use warnings; |
|
|
| 8 |
|
7 |
|
| 9 |
use Test::More tests => 19; |
8 |
use Test::More tests => 22; |
| 10 |
|
9 |
|
| 11 |
BEGIN { |
10 |
BEGIN { |
| 12 |
use_ok('C4::Installer::PerlModules'); |
11 |
use_ok('C4::Installer::PerlModules'); |
| 13 |
} |
12 |
} |
| 14 |
|
13 |
|
| 15 |
$C4::Installer::PerlModules::PERL_DEPS->{'Local::Module::Sort'} = { |
14 |
$C4::Installer::PerlModules::PERL_DEPS->{'Local::Module::Upgraded'} = { |
| 16 |
'required' => '1', |
15 |
'required' => '1', |
| 17 |
'min_ver' => '0.9.3', |
16 |
'min_ver' => '0.9.3', |
| 18 |
'usage' => "Testing: make sure numbers are compared numerically and not lexicographically", |
17 |
'usage' => "Testing: make sure numbers are compared numerically and not lexicographically", |
| 19 |
}; |
18 |
}; |
|
|
19 |
$Local::Module::Upgraded::VERSION = '0.9.13'; |
| 20 |
$INC{"Local/Module/Upgraded.pm"} = 1; |
| 21 |
use_ok("Local::Module::Upgraded"); |
| 20 |
|
22 |
|
| 21 |
$Local::Module::Sort::VERSION = '0.9.13'; |
23 |
$C4::Installer::PerlModules::PERL_DEPS->{'Local::Module::NotUpgraded'} = { |
| 22 |
$INC{"Local/Module/Sort.pm"} = 1; |
24 |
'required' => '1', |
| 23 |
use_ok("Local::Module::Sort"); |
25 |
'min_ver' => '0.9.3', |
|
|
26 |
'usage' => "Testing: make sure numbers are compared numerically and not lexicographically", |
| 27 |
}; |
| 28 |
$Local::Module::NotUpgraded::VERSION = '0.9.1'; |
| 29 |
$INC{"Local/Module/NotUpgraded.pm"} = 1; |
| 30 |
use_ok("Local::Module::NotUpgraded"); |
| 24 |
|
31 |
|
| 25 |
my $modules; |
32 |
my $modules; |
| 26 |
ok ($modules = C4::Installer::PerlModules->new(), 'Tests modules object'); |
33 |
ok ($modules = C4::Installer::PerlModules->new(), 'Tests modules object'); |
|
Lines 37-51
my $optional = $modules->required('optional'=>1);
Link Here
|
| 37 |
%params = map { $_ => 1 } @$optional; |
44 |
%params = map { $_ => 1 } @$optional; |
| 38 |
ok (exists($params{"Test::Strict"}), 'test::strict optional for installer to run'); |
45 |
ok (exists($params{"Test::Strict"}), 'test::strict optional for installer to run'); |
| 39 |
is ($optional = $modules->required('spaghetti'=>1),-1, '-1 returned when parsing in unknown parameter'); |
46 |
is ($optional = $modules->required('spaghetti'=>1),-1, '-1 returned when parsing in unknown parameter'); |
| 40 |
my $version_info = $modules->version_info('module'=>"DBI"); |
47 |
my $version_info = $modules->version_info('DBI'); |
| 41 |
ok (exists($version_info->{'DBI'}->{"required"}), 'required exists'); |
48 |
ok (exists($version_info->{"required"}), 'required exists'); |
| 42 |
ok (exists($version_info->{'DBI'}->{"upgrade"}), 'upgrade exists'); |
49 |
ok (exists($version_info->{"upgrade"}), 'upgrade exists'); |
| 43 |
is ($modules->version_info('module'=>"thisdoesn'texist"),-1, 'thisdoesntexist should return -1'); |
50 |
is ($modules->version_info("thisdoesn'texist"),-1, 'thisdoesntexist should return -1'); |
| 44 |
ok ($modules->module_count() >10 , 'count should be greater than 10'); |
51 |
ok ($modules->module_count() >10 , 'count should be greater than 10'); |
| 45 |
my @module_list = $modules->module_list; |
52 |
my @module_list = $modules->module_list; |
| 46 |
%params = map { $_ => 1 } @module_list; |
53 |
%params = map { $_ => 1 } @module_list; |
| 47 |
ok (exists($params{"DBI"}), 'DBI exists in array'); |
54 |
ok (exists($params{"DBI"}), 'DBI exists in array'); |
| 48 |
is ($modules->required('module'=>"String::Random"),1, 'String::Random should return 1 since required'); |
55 |
is ($modules->required('module'=>"String::Random"),1, 'String::Random should return 1 since required'); |
| 49 |
ok (!$modules->version_info(), "Testing empty modules"); |
56 |
is ($modules->version_info(), -1, "Testing empty modules"); |
|
|
57 |
|
| 58 |
is($modules->version_info("Local::Module::Upgraded")->{"upgrade"},0,"Version 0.9.13 is greater than 0.9.3, so no upgrade needed"); |
| 59 |
is($modules->version_info("Local::Module::NotUpgraded")->{"upgrade"},1,"Version 0.9.1 is smaller than 0.9.1, so no upgrade needed"); |
| 50 |
|
60 |
|
| 51 |
is($modules->version_info('module'=>"Local::Module::Sort")->{"Local::Module::Sort"}->{"upgrade"},0,"Version 0.9.13 is greater than 0.9.3, so no upgrade needed"); |
61 |
subtest 'versions_info' => sub { |
|
|
62 |
plan tests => 4; |
| 63 |
my $modules = C4::Installer::PerlModules->new; |
| 64 |
$modules->versions_info; |
| 65 |
ok( exists $modules->{missing_pm}, 'versions_info fills the missing_pm key' ); |
| 66 |
ok( exists $modules->{upgrade_pm}, 'versions_info fills the upgrade_pm key' ); |
| 67 |
ok( exists $modules->{current_pm}, 'versions_info fills the current_pm key' ); |
| 68 |
my $missing_modules = $modules->get_attr( 'missing_pm' ); |
| 69 |
my $upgrade_modules = $modules->get_attr( 'upgrade_pm' ); |
| 70 |
my $current_modules = $modules->get_attr( 'current_pm' ); |
| 71 |
my $dbi_is_missing = grep { exists $_->{DBI} ? 1 : () } @$missing_modules; |
| 72 |
my $dbi_is_upgrade = grep { exists $_->{DBI} ? 1 : () } @$upgrade_modules; |
| 73 |
my $dbi_is_current = grep { exists $_->{DBI} ? 1 : () } @$current_modules; |
| 74 |
ok( $dbi_is_missing || $dbi_is_upgrade || $dbi_is_current, 'DBI should either be missing, upgrade or current' ); |
| 75 |
}; |