From ae9212f774a28f9c6095c86dc59df2bbbffb5f91 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 9 Jan 2019 07:33:15 -0300 Subject: [PATCH] Bug 22084: Regression tests Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall Signed-off-by: Josef Moravec --- t/db_dependent/Plugins.t | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t index d3447c3..7bbd8d9 100755 --- a/t/db_dependent/Plugins.t +++ b/t/db_dependent/Plugins.t @@ -9,9 +9,10 @@ use File::Temp qw( tempdir tempfile ); use FindBin qw($Bin); use Module::Load::Conditional qw(can_load); use Test::MockModule; -use Test::More tests => 41; +use Test::More tests => 42; use C4::Context; +use Koha::Database; use t::lib::Mocks; @@ -24,6 +25,8 @@ BEGIN { use_ok('Koha::Plugin::Test'); } +my $schema = Koha::Database->new->schema; + my $mock_plugin = Test::MockModule->new( 'Koha::Plugin::Test' ); $mock_plugin->mock( 'test_template', sub { my ( $self, $file ) = @_; @@ -157,6 +160,28 @@ subtest 'output and output_html tests' => sub { like($stdout, qr{¡Hola output_html!}, 'Correct data'); }; +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; +}; + + subtest 'Test _version_compare' => sub { plan tests => 6; -- 2.1.4