CGI-Alert

 view release on metacpan or  search on metacpan

t/03http_die.t  view on Meta::CPAN

# -*- perl -*-
#

use strict;
use warnings;

use Test::More;
use Test::Differences;
use File::Temp	'tempfile';

umask 077;

my ($script_fh, $script_path) = tempfile( "CGI-Alert-t-03.script.XXXXXX" );
my (undef,      $output_path) = tempfile( "CGI-Alert-t-03.output.XXXXXX" );

printf $script_fh <<'-', $^X, $output_path, $output_path;
#!%s -Tw -Iblib/lib

use CGI::Alert		qw(nobody http_die);

# Not interested in any email being sent
$SIG{__DIE__}  = 'DEFAULT';
$SIG{__WARN__} = sub { print STDOUT @_ };

# FIXME-document
package CGI;
use subs qw(header start_html);
package main;

*CGI::header = sub {
    print "header()\n";
    use Data::Dumper; print Dumper(\@_);
};
*CGI::start_html = sub {
    print "start_html()\n";
    use Data::Dumper; print Dumper(\@_);
};

# Pretend that we've loaded CGI module
$INC{'CGI.pm'} = 'HACK ALERT';

open STDOUT, '>', '%s'
  or die "Cannot create %s: $!\n";

CGI::Alert::extra_html_headers(
		-author  => 'esm@cpan.org',
		-style   => {
			     -src  => '/foo.css',
			    },
	       );


# Here we go.
http_die '400 Bad Request', 'this is the body';
-


close $script_fh;

chmod 0500 => $script_path;

my $expect = do { local $/; <DATA>; };

plan tests => 2;

{
    local %ENV =
      (



( run in 0.827 second using v1.01-cache-2.11-cpan-0b5f733616e )