0.11_09 commit
[bse.git] / t / t10edit.t
1 #!perl -w
2 use strict;
3 use BSE::Test qw(base_url make_ua fetch_ok skip check_form post_ok ok);
4
5 ++$|;
6 print "1..25\n";
7 my $baseurl = base_url;
8 my $ua = make_ua;
9 my $headers;
10 my $content = 
11   fetch_ok($ua, "edit page", 
12            "$baseurl/cgi-bin/admin/add.pl?level=1&parentid=-1",
13            qr!No\s+parent\s+-\s+this\s+is\s+a\s+section
14            .*
15            common/default.tmpl
16            .*
17            Add\s+New\s+Section
18            !xs);
19 if ($content) {
20   check_form($content,
21              "edit form",
22              parentid=>[ -1, 'select' ],
23              id => [ '', 'hidden' ],
24              titleImage => [ '', 'select' ],
25              template=> [ 'common/default.tmpl', 'select' ],
26              body => [ '<maximum of 64Kb>', 'textarea' ],
27              listed => [ 1, 'select' ],
28              );
29 }
30 else {
31   skip("no content to check", 18);
32 }
33
34 my ($code, $good);
35 ($content, $code, $good, $headers) = 
36   post_ok($ua, "adding article", "$baseurl/cgi-bin/admin/add.pl",
37           [
38            parentid=>-1,
39            level => 1,
40            title=>"Test Article",
41            titleImage=>'',
42            template=>'common/default.tmpl',
43            body=>'This is a test body',
44            release=>'',
45            expire=>'',
46            summaryLength => '',
47            displayThreshold=>'',
48            keywords=>'',
49            listed=>1,
50            save=>1,
51           ], undef, qr!Refresh:\s+0!);
52 if ($good) {
53   $headers =~ /Refresh:\s+\d+\s*;\s+url=(\"?)([^\"\'\n\r;]+)(\1)/
54     or die "Someone lied";
55   my $url = $2;
56   print "# $url\n";
57   ok($url =~ m!/cgi-bin/admin/admin\.pl\?!, "check admin mode url");
58   fetch_ok($ua, "admin mode", $url,
59            qr!
60            <title>Test\ Server\ -\ Test\ Article</title>
61            .*
62            This\ is\ a\ test\ body
63            !xsm);
64 }
65 else {
66   skip(3);
67 }