I thought I'd help out with some of the mp2 documentation, and
as part of that effort, I thought I'd try to write some tests.

The idea being that it'd be a nice if the documentation reflected
how the code actually worked. :-)

So I thought I'd try writing my first test script and adding it
to mp2 distribution.

Below I've appended a simple test script that checks the $r->content_type
method.

I have a couple of questions about it.

1) Does it look right?  If I'm going to add test scripts, no sense
getting off on the wrong foot.


2) I put it in a file called

./modperl-2.0/t/response/TestModperl/content.pm

I noticed that these modules in this directory seem to generate .t 
files in

./modperl-2.0/t/modperl

What section of code is doing this operation?  I looked around but it
wasn't immediately obvious to me.

3) The script seems to blow if I try to $r->content_type(undef).  I
don't know why you want to do this, but I thought it should be handled.

...or do I just have a bug in my test script?  

Does that mean I need to add some code into mp2 to handle this case? :-)


Thanks for any feedback.




package TestModperl::content;

use strict;
use warnings FATAL => 'all';

use Apache::RequestRec ();

use Apache::Test;

use Apache::Const -compile => 'OK';

sub handler {

    my $r = shift;

    plan $r, tests => 4;

    my $foo = 'text/foo';
    my $gif = 'image/gif';

    my $type = $r->content_type;

    ok $type;

    $r->content_type($foo);

    ok($foo, $r->content_type);        # Does it return what we set it to?

    ok($foo, $r->content_type($gif));  # Return previous type?

    ok($gif, $r->content_type);        # How about now?

    $r->content_type(undef);           # Can we undef this?

    ok(!defined($r->content_type));    # Does undef work?

    Apache::OK;
}

1;
__END__



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to