4 use RT::Test nodb => 1, tests => 89;
7 local $Test::Builder::Level = $Test::Builder::Level + 1;
13 is(warnings_from($option => $value), 0, $name);
16 sub one_warning_like {
17 local $Test::Builder::Level = $Test::Builder::Level + 1;
24 my @w = warnings_from($option => $value);
26 like($w[0], $regex, $name);
35 local $SIG{__WARN__} = sub {
36 push @warnings, $_[0];
39 RT->Config->Set($option => $value);
40 RT->Config->PostLoadCheck;
46 no_warnings_ok(WebPath => '');
47 no_warnings_ok(WebPath => '/foo');
48 no_warnings_ok(WebPath => '/foo/bar');
50 one_warning_like(WebPath => '/foo/', qr/The WebPath config option requires no trailing slash/);
52 one_warning_like(WebPath => 'foo', qr/The WebPath config option requires a leading slash/);
54 my @w = warnings_from(WebPath => 'foo/');
56 like($w[0], qr/The WebPath config option requires no trailing slash/);
57 like($w[1], qr/The WebPath config option requires a leading slash/);
59 one_warning_like(WebPath => '/foo/bar/', qr/The WebPath config option requires no trailing slash/);
61 one_warning_like(WebPath => 'foo/bar', qr/The WebPath config option requires a leading slash/);
63 @w = warnings_from(WebPath => 'foo/bar/');
65 like($w[0], qr/The WebPath config option requires no trailing slash/);
66 like($w[1], qr/The WebPath config option requires a leading slash/);
68 one_warning_like(WebPath => '/', qr{For the WebPath config option, use the empty string instead of /});
70 # reinstate a valid WebPath for other tests
71 no_warnings_ok(WebPath => '/rt');
74 no_warnings_ok(WebDomain => 'example.com');
75 no_warnings_ok(WebDomain => 'rt.example.com');
76 no_warnings_ok(WebDomain => 'localhost');
78 one_warning_like(WebDomain => '', qr{You must set the WebDomain config option});
80 one_warning_like(WebDomain => 'http://rt.example.com', qr{The WebDomain config option must not contain a scheme \(http://\)});
82 one_warning_like(WebDomain => 'https://rt.example.com', qr{The WebDomain config option must not contain a scheme \(https://\)});
84 one_warning_like(WebDomain => 'rt.example.com/path', qr{The WebDomain config option must not contain a path \(/path\)});
86 one_warning_like(WebDomain => 'rt.example.com/path/more', qr{The WebDomain config option must not contain a path \(/path/more\)});
88 one_warning_like(WebDomain => 'rt.example.com:80', qr{The WebDomain config option must not contain a port \(80\)});
90 # reinstate a valid WebDomain for other tests
91 no_warnings_ok(WebDomain => 'rt.example.com');
94 no_warnings_ok(WebDomain => 80);
95 no_warnings_ok(WebDomain => 443);
96 no_warnings_ok(WebDomain => 8888);
98 one_warning_like(WebPort => '', qr{You must set the WebPort config option});
100 one_warning_like(WebPort => 3.14, qr{The WebPort config option must be an integer});
102 one_warning_like(WebPort => 'wha?', qr{The WebPort config option must be an integer});
104 # reinstate a valid WebDomain for other tests
105 no_warnings_ok(WebPort => 443);
108 no_warnings_ok(WebBaseURL => 'http://rt.example.com');
109 no_warnings_ok(WebBaseURL => 'HTTP://rt.example.com', 'uppercase scheme is okay');
110 no_warnings_ok(WebBaseURL => 'http://rt.example.com:8888', 'nonstandard port is okay');
111 no_warnings_ok(WebBaseURL => 'https://rt.example.com:8888', 'nonstandard port with https is okay');
113 one_warning_like(WebBaseURL => '', qr{You must set the WebBaseURL config option});
115 one_warning_like(WebBaseURL => 'rt.example.com', qr{The WebBaseURL config option must contain a scheme});
117 one_warning_like(WebBaseURL => 'xtp://rt.example.com', qr{The WebBaseURL config option must contain a scheme \(http or https\)});
119 one_warning_like(WebBaseURL => 'http://rt.example.com/', qr{The WebBaseURL config option requires no trailing slash});
121 one_warning_like(WebBaseURL => 'http://rt.example.com/rt', qr{The WebBaseURL config option must not contain a path \(/rt\)});
123 @w = warnings_from(WebBaseURL => 'http://rt.example.com/rt/');
125 like($w[0], qr{The WebBaseURL config option requires no trailing slash});
126 like($w[1], qr{The WebBaseURL config option must not contain a path \(/rt/\)});
128 one_warning_like(WebBaseURL => 'http://rt.example.com/rt/ir', qr{The WebBaseURL config option must not contain a path \(/rt/ir\)});
130 @w = warnings_from(WebBaseURL => 'http://rt.example.com/rt/ir/');
132 like($w[0], qr{The WebBaseURL config option requires no trailing slash});
133 like($w[1], qr{The WebBaseURL config option must not contain a path \(/rt/ir/\)});
135 # reinstate a valid WebBaseURL for other tests
136 no_warnings_ok(WebBaseURL => 'http://rt.example.com');
139 no_warnings_ok(WebURL => 'http://rt.example.com/');
140 no_warnings_ok(WebURL => 'HTTP://rt.example.com/', 'uppercase scheme is okay');
141 no_warnings_ok(WebURL => 'http://example.com/rt/');
142 no_warnings_ok(WebURL => 'http://example.com/rt/ir/');
143 no_warnings_ok(WebURL => 'http://rt.example.com:8888/', 'nonstandard port is okay');
144 no_warnings_ok(WebURL => 'https://rt.example.com:8888/', 'nonstandard port with https is okay');
146 one_warning_like(WebURL => '', qr{You must set the WebURL config option});
148 @w = warnings_from(WebURL => 'rt.example.com');
150 like($w[0], qr{The WebURL config option must contain a scheme});
151 like($w[1], qr{The WebURL config option requires a trailing slash});
153 one_warning_like(WebURL => 'http://rt.example.com', qr{The WebURL config option requires a trailing slash});
155 one_warning_like(WebURL => 'xtp://example.com/rt/', qr{The WebURL config option must contain a scheme \(http or https\)});
157 one_warning_like(WebURL => 'http://rt.example.com/rt', qr{The WebURL config option requires a trailing slash});
159 one_warning_like(WebURL => 'http://rt.example.com/rt/ir', qr{The WebURL config option requires a trailing slash});
161 # reinstate a valid WebURL for other tests
162 no_warnings_ok(WebURL => 'http://rt.example.com/rt/');