Boris Sukholitko > HTML-Tested-0.58 > HTML::Tested

Download:
HTML-Tested-0.58.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.58   Source  

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 ^

$class->ht_add_widget($widget_class, $widget_name, @widget_args)

Adds widget implemented by $widget_class to $class as $widget_name. @widget_args are passed as is into $widget_class->new function.

For example, A->ht_add_widget("HTML::Tested::Value", "a", default_value => "b"); will create value widget (and corresponding a accessor) in A class which will have default value "b".

See widget new function documentation for relevant @widget_args values (most of them are documented in HTML::Tested::Value class).

ht_render(stash)

Renders all of the contained controls into the stash. stash should be hash reference.

ht_find_widget($widget_name)

Finds widget named $widget_name.

ht_bless_from_tree(class, tree)

Creates blessed instance of the class from tree.

ht_get_widget_option($widget_name, $option_name)

Gets option $option_name for widget named $widget_name.

ht_set_widget_option($widget_name, $option_name, $value)

Sets option $option_name to $value for widget named $widget_name.

$root->ht_validate

Recursively validates all contained widgets. See HTML::Tested::Value for $widget-validate> method description.

Prepends the names of the widgets which failed validation into result arrays.

$root->ht_make_query_string($uri, @widget_names)

Makes query string from $uri and widget values.

$root->ht_merge_params(@params)

Merges parameters with current values. Tries to reconstruct the state of the controls to user set values.

E.g. for EditBox it means setting its value to one in params. For checkbox - setting its checked state.

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.

syntax highlighting: