NAME
HTML::Tested - Provides HTML widgets with the built-in means of testing.
SYNOPSIS
package MyPage;
use base 'HTML::Tested';
__PACKAGE__->make_tested_value('x');
# Register my own widget
__PACKAGE__->register_tested_widget('my_widget', 'My::App::Widget');
__PACKAGE__->make_tested_my_widget('w');
# Later, in the test for example
package main;
my $p = MyPage->construct_somehow;
$p->x('Hi');
my $stash = {};
$p->ht_render($stash);
# stash contains x => 'Hi'
# We can pass it to templating mechanism
# Stash checking function
my @errors = HTML::Tested::Test->check_stash(
'MyPage', $stash, { x => 'Hi' });
# Stash checking function
my @errors = HTML::Tested::Test->check_text(
'MyPage', '<html>x</html>', { x => 'Hi' });
DISCLAIMER
This is pre-alpha quality software. Please use it on your own risk.
INTRODUCTION
Imagine common web programming scenario - you have HTML page packed with checkboxes, edit boxes, labels etc.
You are probably using some kind of templating mechanism for this page already. However, your generating routine still has quite a lot of complex code.
Now, being an experienced XP programmer, you face the task of writing test code for the routine. Note, that your test code can deal with the results on two levels: we can check the stash that we are going to pass to the templating module or we can crawl our site and check the resulting text.
As you can imagine both of those scenarios require quite a lot of effort to get right.
HTML::Tested can help here. It does this by generating stash data from the widgets that you declare. Its testing code can check the existence of those widgets both in the stash and in the text of the page.
METHODS
register_tested_widget(widget_name, widget_class, dont_use)
Registers widget to be available for the inheriting classes. This implicitly creates make_tested_<widget_name> function. widget_class
should provide behind the scenes support for the widget. dont_use
tells HTML::Tested to not use the module at the time of loading.
ht_render(stash)
Renders all of the contained controls into the stash. stash
should be hash reference.
ht_bless_from_tree(class, tree)
Creates blessed instance of the class from tree.
ht_convert_request_to_tree(class, r)
Creates blessed instance of the class from Apache::Request compatible object.
BUGS
Documentation is too sparse to be taken seriously.
AUTHOR
Boris Sukholitko
CPAN ID: BOSU
boriss@gmail.com
COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
SEE ALSO
HTML::Tested::Test for writing tests using HTML::Tested. See HTML::Tested::Value::* for the documentation on the specific widgets. See HTML::Tested::List for documentation on list container.