Bug 21116: Unit tests
[koha.git] / t / lib / Koha / Plugin / Test.pm
blobf817438986bdd8298e4a397c7824c524722f78ee
1 package Koha::Plugin::Test;
3 ## It's good practice to use Modern::Perl
4 use Modern::Perl;
6 use Mojo::JSON qw(decode_json);
8 ## Required for all plugins
9 use base qw(Koha::Plugins::Base);
11 our $VERSION = 1.01;
12 our $metadata = {
13 name => 'Test Plugin',
14 author => 'Kyle M Hall',
15 description => 'Test plugin',
16 date_authored => '2013-01-14',
17 date_updated => '2013-01-14',
18 minimum_version => '3.11',
19 maximum_version => undef,
20 version => $VERSION,
21 my_example_tag => 'find_me',
24 ## This is the minimum code required for a plugin's 'new' method
25 ## More can be added, but none should be removed
26 sub new {
27 my ( $class, $args ) = @_;
28 $args->{'metadata'} = $metadata;
29 my $self = $class->SUPER::new($args);
30 return $self;
33 sub report {
34 my ( $self, $args ) = @_;
35 return "Koha::Plugin::Test::report";
38 sub tool {
39 my ( $self, $args ) = @_;
40 return "Koha::Plugin::Test::tool";
43 sub to_marc {
44 my ( $self, $args ) = @_;
45 return "Koha::Plugin::Test::to_marc";
48 sub opac_online_payment {
49 my ( $self, $args ) = @_;
50 return "Koha::Plugin::Test::opac_online_payment";
53 sub opac_online_payment_begin {
54 my ( $self, $args ) = @_;
55 return "Koha::Plugin::Test::opac_online_payment_begin";
58 sub opac_online_payment_end {
59 my ( $self, $args ) = @_;
60 return "Koha::Plugin::Test::opac_online_payment_end";
63 sub opac_head {
64 my ( $self, $args ) = @_;
65 return "Koha::Plugin::Test::opac_head";
68 sub opac_js {
69 my ( $self, $args ) = @_;
70 return "Koha::Plugin::Test::opac_js";
73 sub configure {
74 my ( $self, $args ) = @_;
75 return "Koha::Plugin::Test::configure";;
78 sub install {
79 my ( $self, $args ) = @_;
80 return "Koha::Plugin::Test::install";
83 sub uninstall {
84 my ( $self, $args ) = @_;
85 return "Koha::Plugin::Test::uninstall";
88 sub test_output {
89 my ( $self ) = @_;
90 $self->output( '¡Hola output!', 'json' );
93 sub test_output_html {
94 my ( $self ) = @_;
95 $self->output_html( '¡Hola output_html!' );
98 sub api_namespace {
99 return "testplugin";
102 sub api_routes {
103 my ( $self, $args ) = @_;
105 my $spec = qq{
107 "/patrons/{patron_id}/bother": {
108 "put": {
109 "x-mojo-to": "Koha::Plugin::Test#bother",
110 "operationId": "BotherPatron",
111 "tags": ["patrons"],
112 "parameters": [{
113 "name": "patron_id",
114 "in": "path",
115 "description": "Internal patron identifier",
116 "required": true,
117 "type": "integer"
119 "produces": [
120 "application/json"
122 "responses": {
123 "200": {
124 "description": "A bothered patron",
125 "schema": {
126 "type": "object",
127 "properties": {
128 "bothered": {
129 "description": "If the patron has been bothered",
130 "type": "boolean"
135 "404": {
136 "description": "An error occurred",
137 "schema": {
138 "type": "object",
139 "properties": {
140 "error": {
141 "description": "An explanation for the error",
142 "type": "string"
148 "x-koha-authorization": {
149 "permissions": {
150 "borrowers": "1"
158 return decode_json($spec);