• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kenjis / ci-phpunit-test / 1025

pending completion
1025

push

travis-ci-com

web-flow
Merge pull request #394 from dezsi-istvan/3.x

pre_controller can modify $class / $method

4 of 4 new or added lines in 1 file covered. (100.0%)

1321 of 1739 relevant lines covered (75.96%)

35.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/application/tests/_ci_phpunit_test/CIPHPUnitTestLogger.php
1
<?php
2
/**
3
 * Part of ci-phpunit-test
4
 *
5
 * @author     Kenji Suzuki <https://github.com/kenjis>
6
 * @license    MIT License
7
 * @copyright  2020 Kenji Suzuki
8
 * @link       https://github.com/kenjis/ci-phpunit-test
9
 */
10

11
class CIPHPUnitTestLogger
12
{
13
        /**
14
         * @var array
15
         */
16
        private static $logs = [];
17

18
        private function __construct()
19
        {
20
        }
×
21

22
//        /**
23
//         * @return array
24
//         */
25
//        public static function getLogs()
26
//        {
27
//                return self::$logs;
28
//        }
29

30
        public static function resetLogs()
31
        {
32
                self::$logs = [];
160✔
33
        }
34

35
        /**
36
         * @param string $level
37
         * @param string $message
38
         */
39
        public static function log($level, $message)
40
        {
41
                $trace = debug_backtrace();
162✔
42
                $file  = null;
162✔
43

44
                foreach ($trace as $row)
162✔
45
                {
46
                        if (in_array($row['function'], ['log_message']))
162✔
47
                        {
48
                                $file = self::cleanFileNames($row['file'] ? $row['file'] : '');
162✔
49
                                break;
162✔
50
                        }
51
                }
52

53
                self::$logs[] = [
162✔
54
                        'level' => $level,
162✔
55
                        'message' => $message,
162✔
56
                        'file' => $file,
162✔
57
                ];
162✔
58
        }
59

60
        /**
61
         * @param string $level
62
         * @param string $message
63
         *
64
         * @return bool
65
         */
66
        public static function didLog($level, $message)
67
        {
68
                foreach (self::$logs as $log) {
1✔
69
                        if (strtolower($log['level']) === strtolower($level) && $message === $log['message']) {
1✔
70
                                return true;
1✔
71
                        }
72
                }
73

74
                return false;
×
75
        }
76

77
        /**
78
         * @param string $file
79
         *
80
         * @return string
81
         */
82
        private static function cleanFileNames($file)
83
        {
84
                $file = str_replace(APPPATH, 'APPPATH/', $file);
162✔
85
                $file = str_replace(BASEPATH, 'BASEPATH/', $file);
162✔
86

87
                return str_replace(FCPATH, 'FCPATH/', $file);
162✔
88
        }
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc