/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1172 - (hide 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 dpavlin 369 #!/usr/bin/perl
2     use strict;
3     use warnings;
4    
5     my $debug = @ARGV ? 1 : 0;
6    
7 dpavlin 975 use Test::More tests => 28;
8 dpavlin 369 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 dpavlin 386 diag ref( $required ) if $debug;
20 dpavlin 369 isa_ok( $required, 'ARRAY', 'required' );
21    
22 dpavlin 975 ok( $required = $o->required( as_hash => 1 ), 'required as_hash' );
23     diag dump $required;
24     isa_ok( $required, 'HASH', 'hash' );
25    
26 dpavlin 369 ok( my $attributes = $o->attributes, 'attributes' );
27     diag dump( $attributes ) if $debug;
28     is_deeply( $attributes, ["uri", "feed", "title"], 'attributes' );
29    
30 dpavlin 386 ok( ! $o->params->{uri}, 'no uri' );
31    
32 dpavlin 369 ok( my $html = $o->params_form, 'params_form' );
33     diag $html if $debug;
34     like( $html, qr/<form/, 'has form' );
35 dpavlin 502 unlike( $html, qr/HASH/, 'no HASH' );
36 dpavlin 369
37 dpavlin 386 ok( ! $o->params->{uri}, "don't pollute params" );
38 dpavlin 369
39 dpavlin 386 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 dpavlin 793 ok( $o = Frey::Action->new( class => 'Frey::Class::Browser', debug => $debug, params => { unneeded => 1 } ), "new Frey::Class::Browser" );
52 dpavlin 386 ok( ($html2,$default) = $o->params_form, 'params_form' );
53     ok( ! $html2, 'no form' );
54     ok( $default->{unneeded}, 'preserve params' );
55 dpavlin 469
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 dpavlin 928 ok( $o = Frey::Action->new( class => 'Frey::Introspect', params => { request_url => '/', class => 'Frey' }, debug => $debug ), "new Frey::Introspect" );
62 dpavlin 469 ok( ! $o->params_form, 'params_form empty' );
63 dpavlin 928 diag $o->params_form if $o->params_form;
64 dpavlin 469

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26