diff options
Diffstat (limited to '')
-rw-r--r-- | test/php/error_log/index.php | 3 | ||||
-rw-r--r-- | test/test_php_application.py | 26 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/php/error_log/index.php b/test/php/error_log/index.php new file mode 100644 index 00000000..fd90adfe --- /dev/null +++ b/test/php/error_log/index.php @@ -0,0 +1,3 @@ +<?php +error_log("Error in application"); +?> diff --git a/test/test_php_application.py b/test/test_php_application.py index 1259d22d..d8bfade2 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -1,5 +1,7 @@ import os +import re import shutil +import time import unittest from unit.applications.lang.php import TestApplicationPHP @@ -488,6 +490,30 @@ class TestPHPApplication(TestApplicationPHP): self.get()['body'], r'012345', 'disable_classes before' ) + def test_php_application_error_log(self): + self.load('error_log') + + self.assertEqual(self.get()['status'], 200, 'status') + + time.sleep(1) + + self.assertEqual(self.get()['status'], 200, 'status 2') + + self.stop() + + pattern = r'\d{4}\/\d\d\/\d\d\s\d\d:.+\[notice\].+Error in application' + + self.assertIsNotNone(self.wait_for_record(pattern), 'errors print') + + with open(self.testdir + '/unit.log', 'r', errors='ignore') as f: + errs = re.findall(pattern, f.read()) + + self.assertEqual(len(errs), 2, 'error_log count') + + date = errs[0].split('[')[0] + date2 = errs[1].split('[')[0] + self.assertNotEqual(date, date2, 'date diff') + def test_php_application_script(self): self.assertIn( 'success', |