From 8af1c91bd51a3c1bbab1a4f02311b49203724090 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 2 May 2019 15:51:17 -0300 Subject: [PATCH] Bug 22834: Add tests for Koha::Plugins::Base->bundle_path Signed-off-by: Arthur Suzuki --- t/db_dependent/Plugins.t | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t index c72f27d683..8b30e25594 100755 --- a/t/db_dependent/Plugins.t +++ b/t/db_dependent/Plugins.t @@ -18,7 +18,9 @@ use Modern::Perl; use Archive::Extract; use CGI; +use Cwd qw(abs_path); use File::Basename; +use File::Spec; use File::Temp qw( tempdir tempfile ); use FindBin qw($Bin); use Module::Load::Conditional qw(can_load); @@ -88,27 +90,6 @@ subtest 'Version upgrade tests' => sub { $schema->storage->txn_rollback; }; -subtest 'Version upgrade tests' => sub { - - plan tests => 1; - - $schema->storage->txn_begin; - - my $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } ); - - # make sure there's no version on the DB - $schema->resultset('PluginData') - ->search( { plugin_class => $plugin->{class}, plugin_key => '__INSTALLED_VERSION__' } ) - ->delete; - - $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } ); - my $version = $plugin->retrieve_data('__INSTALLED_VERSION__'); - - is( $version, $plugin->get_metadata->{version}, 'Version has been populated correctly' ); - - $schema->storage->txn_rollback; -}; - $schema->storage->txn_begin; Koha::Plugins::Methods->delete; @@ -272,6 +253,24 @@ subtest 'Test _version_compare' => sub { is( Koha::Plugins::Base::_version_compare( '1.0', '1.0.0' ), 0, "1.0 is equal to 1.0.0" ); }; +subtest 'bundle_path() tests' => sub { + + plan tests => 1; + + t::lib::Mocks::mock_config( 'enable_plugins', 1 ); + + my @current_dir = File::Spec->splitdir(abs_path(__FILE__)); + # remote Plugins.t + pop @current_dir; + # remove db_dependent + pop @current_dir; + + my $plugin = Koha::Plugin::Test->new; + + is( $plugin->bundle_path, File::Spec->catdir(@current_dir) . '/lib/Koha/Plugin/Test' ); + +}; + subtest 'new() tests' => sub { plan tests => 2; @@ -286,4 +285,4 @@ subtest 'new() tests' => sub { is( ref($result), 'Koha::Plugins', 'calling new with enable_plugins makes it override the config' ); }; -$schema->storage->txn_rollback; \ No newline at end of file +$schema->storage->txn_rollback; -- 2.11.0