Debian Codegraph @

t/prerun.t

raw symbols SCIP
1 use Test::Morescip-perl cpan CGI-Application 4.61 Test/More/ tests => 10;
2
3 # Need CGI.pm for tests
4 use CGIscip-perl cpan CGI-Application 4.61 CGI/;
5
6 # Include the test hierarchy
7 use libscip-perl cpan CGI-Application 4.61 lib/ 't/lib';
8
9 # Can we even use this module?
10 use_okscip-perl cpan CGI-Application 4.61 main/use_ok().('TestApp6');
11
12 # Prevent output to STDOUT
13 $ENVscip-perl cpan CGI-Application 4.61 main/`%ENV`.{CGI_APP_RETURN_ONLY} = 1;
14
15 # Test basic cgiapp_prerun() and get_current_runmode()
16 {
17 my $ta_obj = TestApp6->newscip-perl cpan CGI-Application 4.61 TestApp6/new().(QUERY=>CGI->newscip-perl cpan CGI-Application 4.61 CGI/new().(""));
18 my $output = $ta_obj->runscip-perl cpan CGI-Application 4.61 TestApp6/run().();
19
20 # Did the run mode work?
21 likescip-perl cpan CGI-Application 4.61 main/like().($output, qr/^Content\-Type\:\ text\/html/);
22 likescip-perl cpan CGI-Application 4.61 main/like().($output, qr/Hello\ World\:\ prerun\_test\ OK/);
23
24 # Did the cgiapp_prerun work?
25 isscip-perl cpan CGI-Application 4.61 main/is().($ta_obj->paramscip-perl cpan CGI-Application 4.61 TestApp6/param().('PRERUN_RUNMODE'), 'prerun_test');
26
27 # get_current_runmode() working?
28 isscip-perl cpan CGI-Application 4.61 main/is().($ta_obj->get_current_runmodescip-perl cpan CGI-Application 4.61 TestApp6/get_current_runmode().(), 'prerun_test');
29 }
30
31
32 # Test basic prerun_mode()
33 {
34 local($^Wscip-perl cpan CGI-Application 4.61 main/`$^W`.) = undef; # Temporarily disable warnings
35
36 my $ta_obj = TestApp6->newscip-perl cpan CGI-Application 4.61 TestApp6/new().(QUERY=>CGI->newscip-perl cpan CGI-Application 4.61 CGI/new().('rm=prerun_mode_test'));
37 my $output = $ta_obj->runscip-perl cpan CGI-Application 4.61 TestApp6/run().();
38
39 # Did the run mode work?
40 likescip-perl cpan CGI-Application 4.61 main/like().($output, qr/^Content\-Type\:\ text\/html/);
41
42 # We will be in mode 'new_prerun_mode_test' if everything is working
43 likescip-perl cpan CGI-Application 4.61 main/like().($output, qr/Hello\ World\:\ new\_prerun\_mode\_test\ OK/);
44
45 # get_current_runmode() working?
46 isscip-perl cpan CGI-Application 4.61 main/is().($ta_obj->get_current_runmodescip-perl cpan CGI-Application 4.61 TestApp6/get_current_runmode().(), 'new_prerun_mode_test');
47 }
48
49
50 # Test fail-case for prerun_mode()
51 {
52 my $ta_obj = TestApp6->newscip-perl cpan CGI-Application 4.61 TestApp6/new().(QUERY=>CGI->newscip-perl cpan CGI-Application 4.61 CGI/new().('rm=illegal_prerun_mode'));
53
54 eval {
55 my $output = $ta_obj->runscip-perl cpan CGI-Application 4.61 TestApp6/run().();
56 };
57
58 my $eval_error = $@scip-perl cpan CGI-Application 4.61 main/`$@`.;
59
60 # Should result in an error
61 likescip-perl cpan CGI-Application 4.61 main/like().($eval_error, qr/prerun\_mode\(\) can only be called within cgiapp\_prerun\(\)/);
62 }
63
64
65 # Test fail-case for prerun_mode() called from setup()
66 {
67 $ENVscip-perl cpan CGI-Application 4.61 main/`%ENV`.{PRERUN_IN_SETUP} = 1;
68
69 eval {
70 my $ta_obj = TestApp6->newscip-perl cpan CGI-Application 4.61 TestApp6/new().(QUERY=>CGI->newscip-perl cpan CGI-Application 4.61 CGI/new().(""));
71 };
72
73 my $eval_error = $@scip-perl cpan CGI-Application 4.61 main/`$@`.;
74
75 # Should result in an error
76 likescip-perl cpan CGI-Application 4.61 main/like().($eval_error, qr/prerun\_mode\(\) can only be called within cgiapp\_prerun\(\)/);
77 }
78
79
80 ###############
81 #### EOF ####
82 ###############