View | Details | Raw Unified | Return to bug 25131
Collapse All | Expand All

(-)a/t/db_dependent/Koha/REST/Plugin/PluginRoutes.t (-2 / +51 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 2;
20
use Test::More tests => 3;
21
use Test::Mojo;
21
use Test::Mojo;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 118-123 subtest 'Disabled plugins tests' => sub { Link Here
118
    $schema->storage->txn_rollback;
118
    $schema->storage->txn_rollback;
119
};
119
};
120
120
121
subtest 'needs_install use case tests' => sub {
122
123
    plan tests => 2;
124
125
    $schema->storage->txn_begin;
126
127
    # enable plugins
128
    t::lib::Mocks::mock_config( 'enable_plugins', 1 );
129
130
    my $good_plugin;
131
132
    my $plugins = Koha::Plugins->new;
133
    $plugins->InstallPlugins;
134
135
    my @plugins = $plugins->GetPlugins( { all => 1 } );
136
    foreach my $plugin (@plugins) {
137
        $good_plugin = $plugin
138
            if $plugin->{metadata}->{description} eq 'Test plugin';
139
    }
140
141
    # mock Version before initializing the API class
142
    t::lib::Mocks::mock_preference('Version', undef);
143
    # initialize Koha::REST::V1 after mocking
144
    my $t      = Test::Mojo->new('Koha::REST::V1');
145
    my $routes = get_defined_routes($t);
146
147
    # Support placeholders () and <>  (latter style used starting with Mojolicious::Plugin::OpenAPI@1.28)
148
    # TODO: remove () if minimum version is bumped to at least 1.28.
149
    ok(
150
        !exists $routes->{'/contrib/testplugin/patrons/(:patron_id)/bother'}
151
          && !exists $routes->{'/contrib/testplugin/patrons/<:patron_id>/bother'},
152
        'Plugin enabled, route not defined as C4::Context->needs_install is true'
153
    );
154
155
    t::lib::Mocks::mock_preference('Version', '3.0.0');
156
    # re-initialize Koha::REST::V1 after mocking
157
    $t      = Test::Mojo->new('Koha::REST::V1');
158
    $routes = get_defined_routes($t);
159
160
    # Support placeholders () and <>  (latter style used starting with Mojolicious::Plugin::OpenAPI@1.28)
161
    # TODO: remove () if minimum version is bumped to at least 1.28.
162
    ok(
163
        exists $routes->{'/contrib/testplugin/patrons/(:patron_id)/bother'}
164
          || exists $routes->{'/contrib/testplugin/patrons/<:patron_id>/bother'},
165
        'Plugin enabled, route defined as C4::Context->needs_install is false'
166
    );
167
168
    $schema->storage->txn_rollback;
169
};
170
121
sub get_defined_routes {
171
sub get_defined_routes {
122
    my ($t) = @_;
172
    my ($t) = @_;
123
    my $routes = {};
173
    my $routes = {};
124
- 

Return to bug 25131