ZendTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 68
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testNonScalarLog() 0 4 1
A testBadPriority() 0 4 1
A tearDown() 0 3 1
A setUp() 0 17 2
A testLog() 0 4 1
A testLogDebug() 0 4 1
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
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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' );
0 ignored issues
show
Bug introduced by
The type Zend_Log_Writer_Stream was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
35
		$formatter = new \Zend_Log_Formatter_Simple( 'log: %message%' . PHP_EOL );
0 ignored issues
show
Bug introduced by
The type Zend_Log_Formatter_Simple was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
36
		$writer->setFormatter( $formatter );
37
38
		$logger = new \Zend_Log( $writer );
0 ignored issues
show
Bug introduced by
The type Zend_Log was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
39
40
		$filter = new \Zend_Log_Filter_Priority( \Zend_Log::INFO );
0 ignored issues
show
Bug introduced by
The type Zend_Log_Filter_Priority was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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