source: trunk/lib/OpenGuides/Test.pm @ 562

Last change on this file since 562 was 562, checked in by kake, 17 years ago

Pull out common testing code into OpenGuides::Test

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1package OpenGuides::Test;
2
3use strict;
4use vars qw( $VERSION );
5$VERSION = '0.01';
6
7use CGI;
8
9=head1 NAME
10
11OpenGuides::Test - Methods to help test OpenGuides applications.
12
13=head1 DESCRIPTION
14
15Provides methods to help when writing tests for OpenGuides.
16Distributed and installed as part of the OpenGuides project, not
17intended for independent installation.  This documentation is probably
18only useful to OpenGuides developers.
19
20=head1 SYNOPSIS
21
22  use Config::Tiny;
23  use OpenGuides;
24  use OpenGuides::Test;
25
26  my $config = Config::Tiny->new( ... );
27  my $guide = OpenGuides->new( config => $config );
28
29  OpenGuides::Test->write_data(
30                                guide      => $guide,
31                                node       => "Crabtree Tavern",
32                                os_x       => 523465,
33                                os_y       => 177490,
34                                categories => "Pubs",
35                              );
36
37=head1 METHODS
38
39=over 4
40
41=item B<write_data>
42
43  my $guide = OpenGuides->new( config => $config );
44
45  OpenGuides::Test->write_data(
46                                guide      => $guide,
47                                node       => "Crabtree Tavern",
48                                os_x       => 523465,
49                                os_y       => 177490,
50                                categories => "Pubs",
51                              );
52
53=cut
54
55sub write_data {
56    my ($class, %args) = @_;
57   
58    # Set up CGI parameters ready for a node write.
59    # Most of these are in here to avoid uninitialised value warnings.
60    my $q = CGI->new( "" );
61    $q->param( -name => "content", -value => "foo" );
62    $q->param( -name => "categories", -value => $args{categories} || "" );
63    $q->param( -name => "locales", -value => "" );
64    $q->param( -name => "phone", -value => "" );
65    $q->param( -name => "fax", -value => "" );
66    $q->param( -name => "website", -value => "" );
67    $q->param( -name => "hours_text", -value => "" );
68    $q->param( -name => "address", -value => "" );
69    $q->param( -name => "postcode", -value => "" );
70    $q->param( -name => "map_link", -value => "" );
71    $q->param( -name => "os_x", -value => $args{os_x} || "" );
72    $q->param( -name => "os_y", -value => $args{os_y} || "" );
73    $q->param( -name => "osie_x", -value => $args{osie_x} || "" );
74    $q->param( -name => "osie_y", -value => $args{osie_y} || "" );
75    $q->param( -name => "latitude", -value => $args{latitude} || "" );
76    $q->param( -name => "longitude", -value => $args{longitude} || "" );
77    $q->param( -name => "username", -value => "Kake" );
78    $q->param( -name => "comment", -value => "foo" );
79    $q->param( -name => "edit_type", -value => "Normal edit" );
80    $ENV{REMOTE_ADDR} = "127.0.0.1";
81   
82    $args{guide}->commit_node(
83                               return_output => 1,
84                               id => $args{node},
85                               cgi_obj => $q,
86                             );
87}
88
89=back
90
91=head1 AUTHOR
92
93The OpenGuides Project (openguides-dev@openguides.org)
94
95=head1 COPYRIGHT
96
97  Copyright (C) 2004 The OpenGuides Project.  All Rights Reserved.
98
99This module is free software; you can redistribute it and/or modify it
100under the same terms as Perl itself.
101
102=cut
103
1041;
Note: See TracBrowser for help on using the repository browser.