/[Frey]/branches/zimbardo/t/01-Frey-Action.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /branches/zimbardo/t/01-Frey-Action.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1172 - (show annotations)
Sun Jul 5 21:40:16 2009 UTC (14 years, 9 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2041 byte(s)
branch for localisation

1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 my $debug = @ARGV ? 1 : 0;
6
7 use Test::More tests => 28;
8 use lib 'lib';
9
10 use Data::Dump qw/dump/;
11
12 BEGIN {
13 use_ok('Frey::Action');
14 }
15
16 ok( my $o = Frey::Action->new( class => 'Frey::Feed', debug => $debug ), "new Frey::Feed" );
17
18 ok( my $required = $o->required, 'required' );
19 diag ref( $required ) if $debug;
20 isa_ok( $required, 'ARRAY', 'required' );
21
22 ok( $required = $o->required( as_hash => 1 ), 'required as_hash' );
23 diag dump $required;
24 isa_ok( $required, 'HASH', 'hash' );
25
26 ok( my $attributes = $o->attributes, 'attributes' );
27 diag dump( $attributes ) if $debug;
28 is_deeply( $attributes, ["uri", "feed", "title"], 'attributes' );
29
30 ok( ! $o->params->{uri}, 'no uri' );
31
32 ok( my $html = $o->params_form, 'params_form' );
33 diag $html if $debug;
34 like( $html, qr/<form/, 'has form' );
35 unlike( $html, qr/HASH/, 'no HASH' );
36
37 ok( ! $o->params->{uri}, "don't pollute params" );
38
39 ok( my $html2 = $o->params_form, 'params_form again' );
40 diag "1: ",$html;
41 diag "2: ",$html2;
42 cmp_ok( $html, 'eq', $html2, 'repeated same form' );
43
44 my $default;
45 ok( ($html2,$default) = $o->params_form, 'params_form again' );
46 diag "default = ",dump($default) if $debug;
47 ok( $html2, 'got form again' );
48 cmp_ok( $html, 'eq', $html2, 'html same' );
49 ok( $default->{uri}, 'uri has default' );
50
51 ok( $o = Frey::Action->new( class => 'Frey::Class::Browser', debug => $debug, params => { unneeded => 1 } ), "new Frey::Class::Browser" );
52 ok( ($html2,$default) = $o->params_form, 'params_form' );
53 ok( ! $html2, 'no form' );
54 ok( $default->{unneeded}, 'preserve params' );
55
56 ok( $o = Frey::Action->new( class => 'Frey::Introspect', debug => $debug ), "new Frey::Introspect" );
57 ok( $html = $o->params_form, 'params_form' );
58 diag $html if $debug;
59 like( $html, qr/class/, 'required form field class' );
60
61 ok( $o = Frey::Action->new( class => 'Frey::Introspect', params => { request_url => '/', class => 'Frey' }, debug => $debug ), "new Frey::Introspect" );
62 ok( ! $o->params_form, 'params_form empty' );
63 diag $o->params_form if $o->params_form;
64

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26