Koha/t/Installer_PerlModules.t
Jonathan Druart 46f7239b08 Bug 27673: Replace YAML with YAML::XS
From tht YAML pod:

"""
This module has been released to CPAN as YAML::Old, and soon YAML.pm will be changed to just be a frontend interface module for all the various Perl YAML implementation modules, including YAML::Old.

If you want robust and fast YAML processing using the normal Dump/Load API, please consider switching to YAML::XS. It is by far the best Perl module for YAML at this time. It requires that you have a C compiler, since it is written in C.
"""

See also
https://gitlab.com/koha-community/qa-test-tools/-/merge_requests/35

Test plan:
Try some place where YAML::XS is not used and confirm that it works
correctly

QA note: This patch removes some uses of YAML that were not useful

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-02-16 14:54:50 +01:00

35 lines
1.4 KiB
Perl
Executable file

#!/usr/bin/perl
#
# This Koha test module is a stub!
# Add more tests here!!!
use Modern::Perl;
use Test::More tests => 6;
BEGIN {
use_ok('C4::Installer::PerlModules');
}
my $modules;
ok ($modules = C4::Installer::PerlModules->new(), 'Tests modules object');
my $prereq_pm = $modules->prereq_pm();
ok (exists($prereq_pm->{"DBI"}), 'DBI required for installer to run');
ok (exists($prereq_pm->{"CGI"}), 'CGI required for installer to run' );
ok (exists($prereq_pm->{"YAML::XS"}), 'YAML::XS required for installer to run');
subtest 'versions_info' => sub {
plan tests => 4;
my $modules = C4::Installer::PerlModules->new;
$modules->versions_info;
ok( exists $modules->{missing_pm}, 'versions_info fills the missing_pm key' );
ok( exists $modules->{upgrade_pm}, 'versions_info fills the upgrade_pm key' );
ok( exists $modules->{current_pm}, 'versions_info fills the current_pm key' );
my $missing_modules = $modules->get_attr( 'missing_pm' );
my $upgrade_modules = $modules->get_attr( 'upgrade_pm' );
my $current_modules = $modules->get_attr( 'current_pm' );
my $dbi_is_missing = grep { exists $_->{DBI} ? 1 : () } @$missing_modules;
my $dbi_is_upgrade = grep { exists $_->{DBI} ? 1 : () } @$upgrade_modules;
my $dbi_is_current = grep { exists $_->{DBI} ? 1 : () } @$current_modules;
ok( $dbi_is_missing || $dbi_is_upgrade || $dbi_is_current, 'DBI should either be missing, upgrade or current' );
};