1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2018 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\MW\Logger; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Test class for \Aimeos\MW\Logger\Zend. |
15
|
|
|
*/ |
16
|
|
|
class ZendTest extends \PHPUnit\Framework\TestCase |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
private $object; |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Sets up the fixture, for example, opens a network connection. |
23
|
|
|
* This method is called before a test is executed. |
24
|
|
|
* |
25
|
|
|
* @access protected |
26
|
|
|
*/ |
27
|
|
|
protected function setUp() |
28
|
|
|
{ |
29
|
|
|
if( class_exists( 'Zend_Log' ) === false ) { |
30
|
|
|
$this->markTestSkipped( 'Class \Zend_Log not found' ); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
$writer = new \Zend_Log_Writer_Stream( 'error.log' ); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$formatter = new \Zend_Log_Formatter_Simple( 'log: %message%' . PHP_EOL ); |
|
|
|
|
36
|
|
|
$writer->setFormatter( $formatter ); |
37
|
|
|
|
38
|
|
|
$logger = new \Zend_Log( $writer ); |
|
|
|
|
39
|
|
|
|
40
|
|
|
$filter = new \Zend_Log_Filter_Priority( \Zend_Log::INFO ); |
|
|
|
|
41
|
|
|
$logger->addFilter( $filter ); |
42
|
|
|
|
43
|
|
|
$this->object = new \Aimeos\MW\Logger\Zend( $logger ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Tears down the fixture, for example, closes a network connection. |
49
|
|
|
* This method is called after a test is executed. |
50
|
|
|
* |
51
|
|
|
* @access protected |
52
|
|
|
*/ |
53
|
|
|
protected function tearDown() |
54
|
|
|
{ |
55
|
|
|
unlink( 'error.log' ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
public function testLog() |
60
|
|
|
{ |
61
|
|
|
$this->object->log( 'error' ); |
62
|
|
|
$this->assertEquals( 'log: <message> error' . PHP_EOL, file_get_contents( 'error.log' ) ); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
public function testNonScalarLog() |
67
|
|
|
{ |
68
|
|
|
$this->object->log( array ('error', 'error2', 2) ); |
69
|
|
|
$this->assertEquals( 'log: <message> ["error","error2",2]' . PHP_EOL, file_get_contents( 'error.log' ) ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
public function testLogDebug() |
74
|
|
|
{ |
75
|
|
|
$this->object->log( 'debug', \Aimeos\MW\Logger\Base::DEBUG ); |
76
|
|
|
$this->assertEquals( '', file_get_contents( 'error.log' ) ); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
public function testBadPriority() |
81
|
|
|
{ |
82
|
|
|
$this->setExpectedException('\\Aimeos\\MW\\Logger\\Exception'); |
83
|
|
|
$this->object->log( 'error', -1 ); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths