|
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\Config; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Test class for \Aimeos\MW\Config\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_Config' ) === false ) { |
|
30
|
|
|
$this->markTestSkipped( 'Class \Zend_Config not found' ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
$dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'testfiles'; |
|
34
|
|
|
$dir2 = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'testowrite'; |
|
35
|
|
|
|
|
36
|
|
|
$conf = new \Zend_Config( array( 'resource' => array( 'db' => array( 'host' => '127.0.0.1' ) ) ), true ); |
|
|
|
|
|
|
37
|
|
|
$this->object = new \Aimeos\MW\Config\Zend( $conf, array( $dir, $dir2 ) ); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Tears down the fixture, for example, closes a network connection. |
|
43
|
|
|
* This method is called after a test is executed. |
|
44
|
|
|
* |
|
45
|
|
|
* @access protected |
|
46
|
|
|
*/ |
|
47
|
|
|
protected function tearDown() |
|
48
|
|
|
{ |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function testGet() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->assertEquals( '127.0.0.1', $this->object->get( 'resource/db/host' ) ); |
|
55
|
|
|
|
|
56
|
|
|
$x = $this->object->get( 'config/manager/standard/select', 'defvalue1'); |
|
57
|
|
|
$this->assertEquals( 'select11', $x ); |
|
58
|
|
|
|
|
59
|
|
|
$x = $this->object->get( 'config/provider/delivery/sh/select', 'defvalue2'); |
|
60
|
|
|
$this->assertEquals( 'select2', $x ); |
|
61
|
|
|
|
|
62
|
|
|
$x = $this->object->get( 'subconfig/standard/subitem/a/aa', 'defvalue3'); |
|
63
|
|
|
$this->assertEquals( '111', $x ); |
|
64
|
|
|
|
|
65
|
|
|
$x = $this->object->get( 'subconfig/subsubconfig/standard/subsubitem/aa/aaa', 'defvalue4'); |
|
66
|
|
|
$this->assertEquals( '111', $x ); |
|
67
|
|
|
|
|
68
|
|
|
$x = $this->object->get( 'config/manager/standard/select', 'defvalue5'); |
|
69
|
|
|
$this->assertEquals( 'select11', $x ); |
|
70
|
|
|
|
|
71
|
|
|
$x = $this->object->get( 'subconfig/subsubconfig/standard/subsubitem/aa/aaa', 'defvalue6'); |
|
72
|
|
|
$this->assertEquals( '111', $x ); |
|
73
|
|
|
|
|
74
|
|
|
$x = $this->object->get( 'subconfig/standard/subitem/a/aa', 'defvalue7'); |
|
75
|
|
|
$this->assertEquals( '111', $x ); |
|
76
|
|
|
|
|
77
|
|
|
$x = $this->object->get( 'subconfig/standard/subitem/a/bb', 'defvalue8'); |
|
78
|
|
|
$this->assertEquals( 'defvalue8', $x ); |
|
79
|
|
|
|
|
80
|
|
|
$x = $this->object->get( 'nonsubconfig', 'defvalue9'); |
|
81
|
|
|
$this->assertEquals( 'defvalue9', $x ); |
|
82
|
|
|
|
|
83
|
|
|
$x = $this->object->get( 'subconfig', 'defvalue10'); |
|
84
|
|
|
$this->assertInternalType( 'array', $x ); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
public function testGetArray() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->assertEquals( array( 'host' => '127.0.0.1' ), $this->object->get( 'resource/db/' ) ); |
|
91
|
|
|
|
|
92
|
|
|
$this->assertEquals( |
|
93
|
|
|
array( |
|
94
|
|
|
'subitem' => array ( |
|
95
|
|
|
'a' => array( |
|
96
|
|
|
'aa' => '111', |
|
97
|
|
|
), |
|
98
|
|
|
), |
|
99
|
|
|
'subbla' => array( |
|
100
|
|
|
'b' => array ( |
|
101
|
|
|
'bb' => '22', |
|
102
|
|
|
), |
|
103
|
|
|
), |
|
104
|
|
|
), |
|
105
|
|
|
$this->object->get( 'subconfig/standard' |
|
106
|
|
|
) |
|
107
|
|
|
); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
public function testGetDefault() |
|
112
|
|
|
{ |
|
113
|
|
|
$this->assertEquals( 3306, $this->object->get( 'resource/db/port', 3306 ) ); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
public function testSet() |
|
118
|
|
|
{ |
|
119
|
|
|
$this->object->set( 'resource/db/database', 'testdb' ); |
|
120
|
|
|
$this->assertEquals( 'testdb', $this->object->get( 'resource/db/database' ) ); |
|
121
|
|
|
|
|
122
|
|
|
$this->object->set( 'resource/foo', 'testdb' ); |
|
123
|
|
|
$this->assertEquals( 'testdb', $this->object->get( 'resource/foo' ) ); |
|
124
|
|
|
|
|
125
|
|
|
$this->object->set( 'resource/bar/db', 'testdb' ); |
|
126
|
|
|
$this->assertEquals( 'testdb', $this->object->get( 'resource/bar/db' ) ); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
|
|
130
|
|
|
public function testSetArray() |
|
131
|
|
|
{ |
|
132
|
|
|
$this->object->set( 'resource/ldap/', array( 'host' => 'localhost', 'port' => 389 ) ); |
|
133
|
|
|
$this->assertEquals( array( 'host' => 'localhost', 'port' => 389 ), $this->object->get( 'resource/ldap' ) ); |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|
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