root/Apache-Clickable/trunk/t/lib/FilterTest.pm

Revision 636 (checked in by miyagawa, 18 years ago)

0.02

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 package FilterTest;
2 # should be separated into Filter testing module.
3
4 use strict;
5 use vars qw(@ISA @EXPORT);
6
7 require Exporter;
8 @ISA = qw(Exporter);
9 @EXPORT = qw(filters);
10
11 # Can't load Apache::File
12 require FileHandle;
13 @Apache::File::ISA = qw(FileHandle);
14
15 use Apache::FakeRequest;
16
17 sub filters {
18     my($file, $class, $config) = @_;
19     my $r = Apache::FakeRequest->new(
20         content_type => 'text/html',
21         is_main => 1,
22         filename => $file,
23     );
24
25     my $out;
26     local $^W;
27     local *Apache::FakeRequest::print = sub {
28         shift;
29         $out .= join '', @_;
30     };
31
32     if (ref($config) eq 'HASH') {
33         no strict 'refs';
34         local $^W;              # subroutine redefined warning
35         *{"Apache::FakeRequest::dir_config"} = sub {
36             my($r, $cfgkey) = @_;
37             return $config->{$cfgkey};
38         };
39     }
40
41     no strict 'refs';
42     &{$class. "::handler"}($r);
43     return $out;
44 }
45
46
47 1;
Note: See TracBrowser for help on using the browser.