my ( $self, $args ) = @_;
return "Koha::Plugin::Test::uninstall";
}
+
+sub test_output {
+ my ( $self ) = @_;
+ $self->output( '¡Hola output!', 'json' );
+}
+
+sub test_output_html {
+ my ( $self ) = @_;
+ $self->output_html( '¡Hola output_html!' );
+}
use Modern::Perl;
-use Test::More tests => 32;
+use Test::More tests => 33;
use CGI;
use File::Basename;
use File::Spec;
is( @$info, 0, "Table $table does no longer exist" );
ok( !( -f $full_pm_path ), "Koha::Plugins::Handler::delete works correctly." );
}
+
+subtest 'output and output_html tests' => sub {
+
+ plan tests => 6;
+
+ # Trick stdout to be able to test
+ local *STDOUT;
+ my $stdout;
+ open STDOUT, '>', \$stdout;
+
+ my $plugin = Koha::Plugin::Test->new({ enable_plugins => 1, cgi => CGI->new });
+ $plugin->test_output;
+
+ like($stdout, qr/Cache-control: no-cache/, 'force_no_caching sets Cache-control as desired');
+ like($stdout, qr{Content-Type: application/json; charset=UTF-8}, 'Correct content-type');
+ like($stdout, qr{¡Hola output!}, 'Correct data');
+
+ # reset the stdout buffer
+ $stdout = '';
+ close STDOUT;
+ open STDOUT, '>', \$stdout;
+
+ $plugin->test_output_html;
+
+ like($stdout, qr/Cache-control: no-cache/, 'force_no_caching sets Cache-control as desired');
+ like($stdout, qr{Content-Type: text/html; charset=UTF-8}, 'Correct content-type');
+ like($stdout, qr{¡Hola output_html!}, 'Correct data');
+};