1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2018 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Logger; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Test class for \Aimeos\MW\Logger\Zend2. |
14
|
|
|
*/ |
15
|
|
|
class Zend2Test extends \PHPUnit\Framework\TestCase |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
private $object; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Sets up the fixture, for example, opens a network connection. |
22
|
|
|
* This method is called before a test is executed. |
23
|
|
|
* |
24
|
|
|
* @access protected |
25
|
|
|
*/ |
26
|
|
|
protected function setUp() |
27
|
|
|
{ |
28
|
|
|
if( class_exists( 'Zend\Log\Logger' ) === false ) { |
29
|
|
|
$this->markTestSkipped( 'Class Zend\Log\Logger not found' ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
$writer = new \Zend\Log\Writer\Stream( 'error.log' ); |
33
|
|
|
|
34
|
|
|
$formatter = new \Zend\Log\Formatter\Simple( 'log: %message%' . PHP_EOL ); |
35
|
|
|
$writer->setFormatter( $formatter ); |
36
|
|
|
|
37
|
|
|
$filter = new \Zend\Log\Filter\Priority( \Zend\Log\Logger::INFO ); |
38
|
|
|
$writer->addFilter( $filter ); |
39
|
|
|
|
40
|
|
|
$logger = new \Zend\Log\Logger(); |
41
|
|
|
$logger->addWriter( $writer ); |
42
|
|
|
|
43
|
|
|
$this->object = new \Aimeos\MW\Logger\Zend2( $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\n\n", 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]' . "\n\n", 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