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

(-)a/t/db_dependent/Koha/Plugins/Plugins.t (-1 / +15 lines)
Lines 64-70 subtest 'call() tests' => sub { Link Here
64
64
65
    my @plugins;
65
    my @plugins;
66
66
67
    warning_is { @plugins = $plugins->InstallPlugins; } undef;
67
    # Koha::Plugin::Test generates 3 redefined sub warnings, no other warnings
68
    # are expected.
69
    warnings_like { @plugins = $plugins->InstallPlugins; }
70
    [ qr/Subroutine .* redefined/, qr/Subroutine .* redefined/, qr/Subroutine .* redefined/ ];
68
71
69
    foreach my $plugin (@plugins) {
72
    foreach my $plugin (@plugins) {
70
        $plugin->enable();
73
        $plugin->enable();
Lines 315-320 subtest 'Koha::Plugin::Test' => sub { Link Here
315
    @names = map { $_->get_metadata()->{'name'} } @plugins;
318
    @names = map { $_->get_metadata()->{'name'} } @plugins;
316
    is( scalar grep( /^Test Plugin$/, @names), 1, "With all param, GetPlugins found disabled Test Plugin" );
319
    is( scalar grep( /^Test Plugin$/, @names), 1, "With all param, GetPlugins found disabled Test Plugin" );
317
320
321
    subtest 'background jobs' => sub {
322
323
        plan tests => 1;
324
325
        use DDP;
326
        my $job = Koha::BackgroundJob::TestBackgroundJob->new;
327
        $job->process;
328
329
        is(1,1);
330
    };
331
318
    $schema->storage->txn_rollback;
332
    $schema->storage->txn_rollback;
319
};
333
};
320
334
(-)a/t/lib/plugins/Koha/Plugin/Test.pm (+18 lines)
Lines 5-12 use Modern::Perl; Link Here
5
5
6
use Koha::Exception;
6
use Koha::Exception;
7
use Koha::Plugins::Tab;
7
use Koha::Plugins::Tab;
8
use Koha::Schema;
8
9
9
use MARC::Field;
10
use MARC::Field;
11
use Module::Metadata;
10
use Mojo::JSON qw( decode_json );
12
use Mojo::JSON qw( decode_json );
11
13
12
use t::lib::TestBuilder;
14
use t::lib::TestBuilder;
Lines 28-33 our $metadata = { Link Here
28
    my_example_tag  => 'find_me',
30
    my_example_tag  => 'find_me',
29
};
31
};
30
32
33
BEGIN {
34
    my $path = Module::Metadata->find_module_by_name(__PACKAGE__);
35
    $path =~ s!\.pm$!/lib!;
36
    unshift @INC, $path;
37
38
    require Koha::Potatoes;
39
    require Koha::Schema::Result::Potatoe;
40
41
    # register the additional schema classes
42
    Koha::Schema->register_class( Potatoe => 'Koha::Schema::Result::Potatoe' );
43
44
    # ... and force a refresh of the database handle so that it includes
45
    # the new classes
46
    Koha::Database->schema( { new => 1 } );
47
}
48
31
## This is the minimum code required for a plugin's 'new' method
49
## This is the minimum code required for a plugin's 'new' method
32
## More can be added, but none should be removed
50
## More can be added, but none should be removed
33
sub new {
51
sub new {
(-)a/t/lib/plugins/Koha/Plugin/Test/TestBackgroundJob.pm (+56 lines)
Line 0 Link Here
1
package Koha::BackgroundJob::TestBackgroundJob;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use base 'Koha::BackgroundJob';
23
24
=head1 NAME
25
26
TestBackgroundJob - Dummy background job for testing
27
28
This is a subclass of Koha::BackgroundJob.
29
30
=head1 API
31
32
=head2 Class methods
33
34
=head3 job_type
35
36
Define the job type of this job.
37
38
=cut
39
40
sub job_type {
41
    return 'test_background_job';
42
}
43
44
=head3 process
45
46
=cut
47
48
sub process {
49
    my ( $self, $args ) = @_;
50
51
    use DDP;
52
    my $schema = Koha::Database->new()->schema();
53
    p($schema->source_registrations->{Potatoe});
54
}
55
56
1;
(-)a/t/lib/plugins/Koha/Plugin/Test/lib/Koha/Potato.pm (+40 lines)
Line 0 Link Here
1
package Koha::Potato;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use base qw(Koha::Object);
23
24
=head1 NAME
25
26
Koha::Potato - Koha Potato Object class
27
28
=head1 API
29
30
=head2 Internal methods
31
32
=head3 _type
33
34
=cut
35
36
sub _type {
37
    return 'Potatoe';
38
}
39
40
1;
(-)a/t/lib/plugins/Koha/Plugin/Test/lib/Koha/Potatoes.pm (+45 lines)
Line 0 Link Here
1
package Koha::Potatoes;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
use Koha::Potato;
22
23
use base qw(Koha::Objects);
24
25
=head1 NAME
26
27
Koha::Potatoes - Koha Potato Object set class
28
29
=head1 API
30
31
=head2 Internal methods
32
33
=head3 _type
34
35
=cut
36
37
sub _type {
38
    return 'Potatoe';
39
}
40
41
sub object_class {
42
    return 'Koha::Potato';
43
}
44
45
1;
(-)a/t/lib/plugins/Koha/Plugin/Test/lib/Koha/Schema/Result/Potatoe.pm (-1 / +65 lines)
Line 0 Link Here
0
- 
1
use utf8;
2
package Koha::Schema::Result::Potatoe;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::Potatoe
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<potatoes>
19
20
=cut
21
22
__PACKAGE__->table("potatoes");
23
24
=head1 ACCESSORS
25
26
=head2 potato_id
27
28
  data_type: 'integer'
29
  is_auto_increment: 1
30
  is_nullable: 0
31
32
=head2 name
33
34
  data_type: 'varchar'
35
  is_nullable: 0
36
  size: 255
37
38
=cut
39
40
__PACKAGE__->add_columns(
41
  "potato_id",
42
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
43
  "name",
44
  { data_type => "varchar", is_nullable => 0, size => 255 },
45
);
46
47
=head1 PRIMARY KEY
48
49
=over 4
50
51
=item * L</potato_id>
52
53
=back
54
55
=cut
56
57
__PACKAGE__->set_primary_key("potato_id");
58
59
60
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-07-23 13:28:28
61
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PpqJllhQ+/CfOjwd/smUjA
62
63
64
# You can replace this text with custom code or comments, and it will be preserved on regeneration
65
1;

Return to bug 36736