File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
appengine/standard/logging Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 2626 <filter >
2727 <whitelist >
2828 <file >index.php</file >
29+ <file >syslog.php</file >
2930 </whitelist >
3031 </filter >
3132</phpunit >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ $ user_is_authorized = !empty ($ _GET ['authorized ' ]);
4+
5+ # [START syslog]
6+ if ($ user_is_authorized ) {
7+ syslog (LOG_INFO , 'Authorized access ' );
8+ echo 'true ' ;
9+ } else {
10+ syslog (LOG_WARNING , 'Unauthorized access ' );
11+ echo 'false ' ;
12+ }
13+ # [END syslog]
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public function testSomeLogs()
6161 include __DIR__ . '/../index.php ' ;
6262 $ result = ob_get_contents ();
6363 ob_end_clean ();
64- // Make sure it looks like Shakespeare.
64+
6565 $ this ->assertContains ('127.0.0.1 ' , $ result );
6666 $ this ->assertContains ('log-status-1 ' , $ result );
6767 $ this ->assertContains ('log-method-1 ' , $ result );
@@ -70,4 +70,24 @@ public function testSomeLogs()
7070 $ this ->assertContains ('applog-message-1 ' , $ result );
7171 $ this ->assertContains ($ d2 ->format ('c ' ), $ result );
7272 }
73+
74+ public function testSyslog ()
75+ {
76+ // not authorized
77+ ob_start ();
78+ include __DIR__ . '/../syslog.php ' ;
79+ $ result = ob_get_contents ();
80+ ob_end_clean ();
81+
82+ $ this ->assertEquals ('false ' , $ result );
83+
84+ // authorized
85+ $ _GET ['authorized ' ] = 1 ;
86+ ob_start ();
87+ include __DIR__ . '/../syslog.php ' ;
88+ $ result = ob_get_contents ();
89+ ob_end_clean ();
90+
91+ $ this ->assertEquals ('true ' , $ result );
92+ }
7393}
You can’t perform that action at this time.
0 commit comments