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

(-)a/t/Koha/Plugin/Test.pm (+10 lines)
Lines 72-74 sub uninstall { Link Here
72
    my ( $self, $args ) = @_;
72
    my ( $self, $args ) = @_;
73
    return "Koha::Plugin::Test::uninstall";
73
    return "Koha::Plugin::Test::uninstall";
74
}
74
}
75
76
sub test_output {
77
    my ( $self ) = @_;
78
    $self->output( '¡Hola output!', 'json' );
79
}
80
81
sub test_output_html {
82
    my ( $self ) = @_;
83
    $self->output_html( '¡Hola output_html!' );
84
}
(-)a/t/db_dependent/Plugins.t (-2 / +29 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 32;
5
use Test::More tests => 33;
6
use CGI;
6
use CGI;
7
use File::Basename;
7
use File::Basename;
8
use File::Spec;
8
use File::Spec;
Lines 121-123 for my $pass ( 1 .. 2 ) { Link Here
121
    is( @$info, 0, "Table $table does no longer exist" );
121
    is( @$info, 0, "Table $table does no longer exist" );
122
    ok( !( -f $full_pm_path ), "Koha::Plugins::Handler::delete works correctly." );
122
    ok( !( -f $full_pm_path ), "Koha::Plugins::Handler::delete works correctly." );
123
}
123
}
124
- 
124
125
subtest 'output and output_html tests' => sub {
126
127
    plan tests => 6;
128
129
    # Trick stdout to be able to test
130
    local *STDOUT;
131
    my $stdout;
132
    open STDOUT, '>', \$stdout;
133
134
    my $plugin = Koha::Plugin::Test->new({ enable_plugins => 1, cgi => CGI->new });
135
    $plugin->test_output;
136
137
    like($stdout, qr/Cache-control: no-cache/, 'force_no_caching sets Cache-control as desired');
138
    like($stdout, qr{Content-Type: application/json; charset=UTF-8}, 'Correct content-type');
139
    like($stdout, qr{¡Hola output!}, 'Correct data');
140
141
    # reset the stdout buffer
142
    $stdout = '';
143
    close STDOUT;
144
    open STDOUT, '>', \$stdout;
145
146
    $plugin->test_output_html;
147
148
    like($stdout, qr/Cache-control: no-cache/, 'force_no_caching sets Cache-control as desired');
149
    like($stdout, qr{Content-Type: text/html; charset=UTF-8}, 'Correct content-type');
150
    like($stdout, qr{¡Hola output_html!}, 'Correct data');
151
};

Return to bug 19223