Skip to content

Commit 57cace3

Browse files
committed
Merge pull request #360 from cakephp/issue-359
Make config() proxy more seamlessly.
2 parents 64f7daa + 1382e59 commit 57cace3

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/Cache/Engine/DebugEngine.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,21 @@ public function groups()
233233
return $this->_engine->groups();
234234
}
235235

236+
/**
237+
* Return the proxied configuration data.
238+
*
239+
* This method uses func_get_args() as not doing so confuses the
240+
* proxied class.
241+
*
242+
* @param string $key The key to set/read.
243+
* @param mixed $value The value to set.
244+
* @param bool $merge Whether or not configuration should be merged.
245+
*/
246+
public function config($key = null, $value = null, $merge = true)
247+
{
248+
return call_user_func_array([$this->_engine, 'config'], func_get_args());
249+
}
250+
236251
/**
237252
* {@inheritDoc}
238253
*/

tests/TestCase/Cache/Engine/DebugEngineTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,40 @@ public function testProxyMethodsTimers()
119119
$this->assertArrayHasKey('Cache.increment key', $result);
120120
$this->assertArrayHasKey('Cache.decrement key', $result);
121121
}
122+
123+
/**
124+
* Test that groups proxies
125+
*
126+
* @return void
127+
*/
128+
public function testGroupsProxies()
129+
{
130+
$engine = new DebugEngine([
131+
'className' => 'File',
132+
'path' => TMP,
133+
'groups' => ['test', 'test2']
134+
]);
135+
$engine->init();
136+
$result = $engine->groups();
137+
$this->assertEquals(['test', 'test2'], $result);
138+
}
139+
140+
/**
141+
* Test that config methods proxy the config data.
142+
*
143+
* @return void
144+
*/
145+
public function testConfigProxies()
146+
{
147+
$engine = new DebugEngine([
148+
'className' => 'File',
149+
'path' => TMP
150+
]);
151+
$engine->init();
152+
153+
$data = $engine->config();
154+
$this->assertArrayHasKey('path', $data);
155+
$this->assertArrayHasKey('isWindows', $data);
156+
$this->assertArrayHasKey('prefix', $data);
157+
}
122158
}

0 commit comments

Comments
 (0)