Changeset 65

Show
Ignore:
Timestamp:
11/23/09 18:54:15 (4 years ago)
Author:
clinton
Message:

Add form tests, tid10737 tid10892 trac18

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/t/lib/MungoTestUtils.pm

    r60 r65  
    1010use Apache::TestRequest qw(GET); 
    1111use Test::More import => [qw(is ok like unlike $TODO)]; 
     12use Test::WWW::Mechanize qw(); 
     13use Data::Dumper; 
     14 
    1215 
    1316=head2 perform_page_tests('/01-foo/', \%tests); 
     
    8285} 
    8386 
     87=head2 $str = get_url_base(); 
     88 
     89Returns a string like 'http://localhost:8529', on which 
     90the test server is running. 
     91 
     92=cut 
     93 
     94push @EXPORT, 'get_url_base'; 
     95sub get_url_base { 
     96    my $cfg = Apache::Test::config(); 
     97    #print Dumper($cfg); 
     98    my $url = $cfg->{vars}->{scheme}  
     99      . '://' 
     100        . $cfg->{vars}->{remote_addr} 
     101          . ':' 
     102            . $cfg->{vars}->{port}; 
     103 
     104    return $url; 
     105} 
     106 
     107=head2 $mech = make_mech(); 
     108 
     109Creates and returns a Test::WWW::Mechanize object.  It will be primed with the 
     110base URL to be that of the test server. 
     111 
     112=cut 
     113 
     114push @EXPORT, 'make_mech'; 
     115sub make_mech { 
     116    my $mech = Test::WWW::Mechanize->new 
     117      ( 
     118       cookie_jar => {},  # enable cookies 
     119       max_redirect => 0, # don't automatically follow redirects 
     120      ); 
     121 
     122    # Do one fetch to set the internal URL base 
     123    $mech->get(get_url_base); 
     124 
     125    return $mech; 
     126} 
     127 
     128 
    841291;