Egg::Helper::O::Test - It assists in the construction of the test environment for Egg.
use Test::More tests=> 3; use Egg::Helper; my $test= Egg::Helper->run('O::Test'); # The test project environment is constructed. $test->prepare; # The object of the test project is acquired. my $egg= $test->egg_virtual; # The environment variable for a virtual request is setup. $egg->setup_env('http://domain.name/hoge?param1=a1¶m2=a2'); # The use of the component of a virtual project is enabled. $egg->prepare_component; ok( $egg->request->params->{param1} eq 'a1' ); # The output contents of a virtual project are acquired. ok( my $catch= $t->response_catch2($egg) ); ok( $$catch );
The construction of a virtual project and other assistances are done so that this module may conveniently test the module related to Egg.
The object of this module is received via Egg::Helper.
my $test= Egg::Helper->run('O::Test');
The environment of a virtual project is temporarily constructed in the directory.
It is necessary to be called always first.
Please see the document of Egg::Helper::O::Test::Prepar in detail.
The object of a virtual project is returned.
The CLEANUP flag of File::Temp::tempdir is specified.
The output contents of a virtual project are returned by the SCALAR reference.
When URL is passed, setup_env is done. Moreover, when [DATA] is passed, it is treated as POST request.
$e->start_engine is done and the output contents are acquired. Therefore, please note uselessness even if [EGG_OBJECT] that did $e->prepare_componet is passed.
Please use 'response_catch2' if you want the result the same as the expectation.
Processing that omits $e->prepare_component because of $e->start_engine is done. It is necessary to do [EGG_OBJECT]->prepare_component beforehand.
Moreover, if it wants the result of a specific request, it is necessary to do setup_env beforehand.
The result of the output of [CODE_REFERENCE] to STDOUT is returned by the SCALAR reference.
The object of a virtual project of the request processing ending is returned. It is ,in a word, an object of the $e->prepare_component processing.
When [REQUEST_METHOD] is POST, the value of [DATA] becomes an option to pass to HTTP::Request::Common.
my $egg= $test->attach_request( POST=> 'http://domain.name/test', { Content_Type=> 'form-data', Content=> [ param1 => 'test', upload1=> ["/path/to/file1"], upload2=> ["/path/to/file2"], ], });
The option to pass to setup_env with the key named ENV can be defined in [DATA].
The environment variable based on passed URL is setup.
HASH passed with [DATA] is developed with the environment variable. All keys are converted into the capital letter.
'Trigger.cgi' that exists in bin of a virtual project is moved.
Passing that builds in the project route of a virtual project is returned.
my $path= $test->path_to('test/test.txt'); ok( $path eq $test->project_root ."/test/test.txt" );
The virtual project name is returned.
The project name can be specified by specifying [PROJECT_NAME].
However, a correct project name cannot be acquired in case of not being after 'prepare' or 'create_project_root' is called.
Passing the route of a virtual project is returned.
However, it is not possible to acquire it in case of not being after 'prepare' or 'create_project_root' is called.
If the project name is undefined, 'project_root' is decided after 'project_name' is defined, and temp_dir is acquired, and the passing is returned.
If [PROJECT_NAME] unspecifies it, 'EggVirtual' becomes default.
The directory of 'project_root' has not been made in this processing yet. Moreover, if 'project_root' already exists, the exception is generated.
The work passing is temporarily returned.
Passing specification can be set beforehand by environment variable 'EGG_TEST_TEMP'. Default becomes passing generated with File::Temp::tempdir.
The content is returned reading the file of [PATH].
Please note the evaluation with path_to about [PATH].
print $test->file_view('lib/MYPROJECT.pm');
File::Temp, Egg::Helper::O::Test::Prepare, Egg::Release,
Masatoshi Mizuno, <mizuno@bomcity.com>
Copyright (C) 2007 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install Egg::Release, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Egg::Release
CPAN shell
perl -MCPAN -e shell install Egg::Release
For more information on module installation, please visit the detailed CPAN module installation guide.