The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTTP::WebTest::SelfTest - Helper package for HTTP::WebTest test suite

SYNOPSIS

    use HTTP::WebTest::SelfTest;

DESCRIPTION

This module provides helper routines used by HTTP::WebTest self test suite. Plugin writers may find this module useful for implementation of test suites for their plugins.

GLOBAL VARIABLES

This module imports in namespace of test script following global variables.

$HOSTNAME

The hostname of the test webserver.

$PORT

The port of the test webserver.

$URL

The URL of the test webserer.

SUBROUTINES

This module imports in namespace of test script following helper subroutines.

abs_url($base, $rel)

Return

Returns absolute URL based on pair of base and relative URLs.

read_file($filename, $ignore_errors)

Reads a file.

Parameters

$filename

Name of the file.

$ignore_errors

(Optional) If true then open file errors are ignored, otherwise they raise an exception. If omit defaults to true.

Returns

Whole content of the file as a string.

write_file($filename, $data)

Writes into a file.

Parameters

$filename

Name of the file.

$data

Data to write into the file.

check_webtest(%params)

Runs a test sequence and compares output with a reference file.

Parameters

webtest => $webtest

HTTP::WebTest object to be used for running the test sequence.

tests => $tests

The test sequence.

tests => $opts

The global parameters for the test sequence.

out_filter => $out_filter

generate_testfile(%params)

Generates test file from template file. I.e. it replaces substring '<<SERVER_URL>>' with value of named parameter server_url.

Parameters

file => $file

Filename of test file. Template file is expected to be in file named "$file.in".

server_url => $server_url

Test webserver URL.

canonical_output(%params)

Some substrings in test output are unique for each test run. This subroutine "fixes" test output so it becomes repeatable (unless tests get broken).

Parameters

output_ref => $output_ref

A reference on scalar which contains test output as whole string.

out_filter => $out_filter

An optional reference on subroutine which can be used as additional filter. It gets passed test output as its first parameter.

server_url => $server_url

Test webserver URL. Normally it is unique for each test run so it gets replaced with http://http.web.test/.

server_hostname => $server_hostname

Test webserver URL. Normally it is unique for each machine where test is run so it gets replaced with http.web.test.

compare_output(%params)

Tests if a test output matches content of specified reference file. If environment variable TEST_FIX is set then the test is always succeed and the content of the reference file is overwritten with current test output.

Parameters

output_ref => $output_ref

A reference on scalar which contains test output as whole string.

check_file => $check_file

Filename of the reference file.

parse_basic_credentials($credentials)

Decodes credentials for Basic authorization scheme according RFC2617.

Returns

Returns user/password pair.

DEPRECATED SUBROUTINES

This module imports in namespace of test script following helper subroutines but they are deprecated and may be removed in the future from this module.

start_webserver

This subroutine was moved into HTTP::WebTest::Utils but for backward compatibility purposes can be exported from this module.

stop_webserver

This subroutine was moved into HTTP::WebTest::Utils but for backward compatibility purposes can be exported from this module.

COPYRIGHT

Copyright (c) 2001-2003 Ilya Martynov. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

HTTP::WebTest

HTTP::WebTest::API

HTTP::WebTest::Plugins