Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
Log: _extractMessage() [Zend Engine 2.0]
3
--SKIPIF--
4
<?php
5
if (version_compare(zend_version(), "2.0.0", "<") ||
6
    version_compare(zend_version(), "2.2.0", ">=")) die('skip');
7
?>
8
--INI--
9
date.timezone=UTC
10
--FILE--
11
<?php
12
 
13
require_once 'Log.php';
14
 
15
$conf = array('lineFormat' => '%2$s [%3$s] %4$s');
16
$logger = Log::singleton('console', '', 'ident', $conf);
17
 
18
/* Logging a regular string. */
19
$logger->log('String');
20
 
21
/* Logging a bare object. */
22
class BareObject {}
23
$logger->log(new BareObject());
24
 
25
/* Logging an object with a getMessage() method. */
26
class GetMessageObject { function getMessage() { return "getMessage"; } }
27
$logger->log(new GetMessageObject());
28
 
29
/* Logging an object with a toString() method. */
30
class ToStringObject { function toString() { return "toString"; } }
31
$logger->log(new ToStringObject());
32
 
33
/* Logging an object with a __toString() method using casting. */
34
class CastableObject { function __toString() { return "__toString"; } }
35
$logger->log(new CastableObject());
36
 
37
/* Logging a PEAR_Error object. */
38
require_once 'PEAR.php';
39
$logger->log(new PEAR_Error('PEAR_Error object', 100));
40
 
41
/* Logging an array. */
42
$logger->log(array(1, 2, 'three' => 3));
43
 
44
/* Logging an array with scalar 'message' keys. */
45
$logger->log(array('message' => 'Message Key'));
46
$logger->log(array('message' => 50));
47
 
48
/* Logging an array with a non-scalar 'message' key. */
49
$logger->log(array('message' => array(1, 2, 3)));
50
 
51
--EXPECT--
52
ident [info] String
53
ident [info] BareObject::__set_state(array(
54
))
55
ident [info] getMessage
56
ident [info] toString
57
ident [info] Object id #2
58
ident [info] PEAR_Error object
59
ident [info] array (
60
 
61
  1 => 2,
62
  'three' => 3,
63
 
64
ident [info] Message Key
65
ident [info] 50
66
ident [info] array (
67
 
68
  1 => 2,
69
  2 => 3,
70
)