[18220] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
[18220] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | define('LOG4PHP_CONFIGURATION', realpath(dirname(__FILE__)) . '/conf/log4php.properties'); |
---|
[18763] | 25 | require_once(realpath(dirname(__FILE__)) . "/../../require.php"); |
---|
[18220] | 26 | require_once(realpath(dirname(__FILE__)) . "/../../../data/class/logger/GC_Logger.php"); |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | * GC_Loggerのテスト |
---|
| 30 | * |
---|
| 31 | * プロパティファイルの内容は以下 |
---|
| 32 | * +--------------------------------------------------------- |
---|
| 33 | * | log4php.rootLogger=DEBUG, R |
---|
| 34 | * | log4php.appender.R=LoggerAppenderEcho |
---|
| 35 | * | log4php.appender.R.layout=LoggerPatternLayout |
---|
| 36 | * | log4php.appender.R.layout.ConversionPattern="[%p] %m%n" |
---|
| 37 | * +--------------------------------------------------------- |
---|
| 38 | * |
---|
| 39 | * @package Logger |
---|
| 40 | * @author LOCKON CO.,LTD. |
---|
| 41 | * @version $Id$ |
---|
| 42 | * |
---|
| 43 | */ |
---|
| 44 | class GC_Logger_Test extends PHPUnit_Framework_TestCase |
---|
| 45 | { |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * インスタンス化のテスト |
---|
| 49 | * |
---|
| 50 | * |
---|
| 51 | */ |
---|
| 52 | function testGfGetInstance(){ |
---|
| 53 | $object1 = GC_Logger::gfGetInstance(); |
---|
| 54 | $object2 = GC_Logger::gfGetInstance(); |
---|
| 55 | |
---|
| 56 | $this->assertSame($object1, $object2); |
---|
| 57 | |
---|
| 58 | $object3 = GC_Logger::gfGetInstance('logger3'); |
---|
| 59 | $object4 = GC_Logger::gfGetInstance('logger4'); |
---|
| 60 | |
---|
| 61 | $this->assertNotSame($object3, $object4); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | /** |
---|
| 65 | * DEBUGログのテスト |
---|
| 66 | * |
---|
| 67 | * |
---|
| 68 | */ |
---|
| 69 | function testGfDebug(){ |
---|
| 70 | $object = GC_Logger::gfGetInstance(); |
---|
| 71 | |
---|
| 72 | ob_start(); |
---|
| 73 | $object->gfDebug('DEBUGログ'); |
---|
| 74 | $buff = ob_get_contents(); |
---|
| 75 | ob_end_clean(); |
---|
| 76 | |
---|
| 77 | $output = "[DEBUG] DEBUGログ\n"; |
---|
| 78 | |
---|
| 79 | $this->assertEquals($buff,$output); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | * DEBUGログ、ダンプテスト |
---|
| 84 | * |
---|
| 85 | * |
---|
| 86 | */ |
---|
| 87 | function testGfDebugDump(){ |
---|
| 88 | $object = GC_Logger::gfGetInstance(); |
---|
| 89 | $a = array('test'); |
---|
| 90 | ob_start(); |
---|
| 91 | $object->gfDebug('a => ', $a); |
---|
| 92 | $buff = ob_get_contents(); |
---|
| 93 | ob_end_clean(); |
---|
| 94 | |
---|
| 95 | $output = |
---|
| 96 | "[DEBUG] a => Array |
---|
| 97 | ( |
---|
| 98 | [0] => test |
---|
| 99 | ) |
---|
| 100 | |
---|
| 101 | "; |
---|
| 102 | $this->assertEquals($buff,$output); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | /** |
---|
| 106 | * INFOログのテスト |
---|
| 107 | * |
---|
| 108 | * |
---|
| 109 | */ |
---|
| 110 | function testGfInfo(){ |
---|
| 111 | $object = GC_Logger::gfGetInstance(); |
---|
| 112 | |
---|
| 113 | ob_start(); |
---|
| 114 | $object->gfInfo('INFOログ'); |
---|
| 115 | $buff = ob_get_contents(); |
---|
| 116 | ob_end_clean(); |
---|
| 117 | |
---|
| 118 | $output = "[INFO] INFOログ\n"; |
---|
| 119 | |
---|
| 120 | $this->assertEquals($buff, $output); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | /** |
---|
| 124 | * INFOログ、ダンプのテスト |
---|
| 125 | * |
---|
| 126 | * |
---|
| 127 | */ |
---|
| 128 | function testGfInfoDump(){ |
---|
| 129 | $object = GC_Logger::gfGetInstance(); |
---|
| 130 | $a = array('test'); |
---|
| 131 | ob_start(); |
---|
| 132 | $object->gfInfo('a => ', $a); |
---|
| 133 | $buff = ob_get_contents(); |
---|
| 134 | ob_end_clean(); |
---|
| 135 | |
---|
| 136 | $output = |
---|
| 137 | "[INFO] a => Array |
---|
| 138 | ( |
---|
| 139 | [0] => test |
---|
| 140 | ) |
---|
| 141 | |
---|
| 142 | "; |
---|
| 143 | $this->assertEquals($buff, $output); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | /** |
---|
| 147 | * ERRORログのテスト |
---|
| 148 | * |
---|
| 149 | * |
---|
| 150 | */ |
---|
| 151 | function testGfError(){ |
---|
| 152 | $object = GC_Logger::gfGetInstance(); |
---|
| 153 | |
---|
| 154 | ob_start(); |
---|
| 155 | $object->gfError('ERRORログ'); |
---|
| 156 | $buff = ob_get_contents(); |
---|
| 157 | ob_end_clean(); |
---|
| 158 | |
---|
| 159 | $output = "[ERROR] ERRORログ\n"; |
---|
| 160 | |
---|
| 161 | $this->assertEquals($buff, $output); |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | /** |
---|
| 165 | * ERRORログ、ダンプのテスト |
---|
| 166 | * |
---|
| 167 | * |
---|
| 168 | */ |
---|
| 169 | function testGfErrorDump(){ |
---|
| 170 | $object = GC_Logger::gfGetInstance(); |
---|
| 171 | $a = array('test'); |
---|
| 172 | ob_start(); |
---|
| 173 | $object->gfError('a => ', $a); |
---|
| 174 | $buff = ob_get_contents(); |
---|
| 175 | ob_end_clean(); |
---|
| 176 | |
---|
| 177 | $output = |
---|
| 178 | "[ERROR] a => Array |
---|
| 179 | ( |
---|
| 180 | [0] => test |
---|
| 181 | ) |
---|
| 182 | |
---|
| 183 | "; |
---|
| 184 | $this->assertEquals($buff, $output); |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | /** |
---|
| 188 | * FATALログのテスト |
---|
| 189 | * |
---|
| 190 | * |
---|
| 191 | */ |
---|
| 192 | function testGfFatal(){ |
---|
| 193 | $object = GC_Logger::gfGetInstance(); |
---|
| 194 | |
---|
| 195 | ob_start(); |
---|
| 196 | $object->gfFatal('FATALログ'); |
---|
| 197 | $buff = ob_get_contents(); |
---|
| 198 | ob_end_clean(); |
---|
| 199 | |
---|
| 200 | $output = "[FATAL] FATALログ\n"; |
---|
| 201 | |
---|
| 202 | $this->assertEquals($buff, $output); |
---|
| 203 | } |
---|
| 204 | |
---|
| 205 | /** |
---|
| 206 | * FATALログ、ダンプのテスト |
---|
| 207 | * |
---|
| 208 | * |
---|
| 209 | */ |
---|
| 210 | function testGfFatalDump(){ |
---|
| 211 | $object = GC_Logger::gfGetInstance(); |
---|
| 212 | $a = array('test'); |
---|
| 213 | ob_start(); |
---|
| 214 | $object->gfFatal('a => ', $a); |
---|
| 215 | $buff = ob_get_contents(); |
---|
| 216 | ob_end_clean(); |
---|
| 217 | |
---|
| 218 | $output = |
---|
| 219 | "[FATAL] a => Array |
---|
| 220 | ( |
---|
| 221 | [0] => test |
---|
| 222 | ) |
---|
| 223 | |
---|
| 224 | "; |
---|
| 225 | $this->assertEquals($buff, $output); |
---|
| 226 | } |
---|
| 227 | } |
---|
[18701] | 228 | ?> |
---|