fix magic __isset()

This commit is contained in:
Ceeram 2012-01-12 11:48:51 +01:00 committed by mark_story
parent b14072aa6f
commit 7badb1d252
2 changed files with 24 additions and 3 deletions

View file

@ -677,7 +677,7 @@ class ViewTest extends CakeTestCase {
$this->attributeEqualTo('_subject', $View)
)
);
$View->Helpers->expects($this->at(4))->method('trigger')
->with(
$this->logicalAnd(
@ -1246,6 +1246,20 @@ TEXT;
$this->assertFalse(isset($this->View->pageTitle));
$this->View->pageTitle = 'test';
$this->assertTrue(isset($this->View->pageTitle));
$this->assertTrue(!empty($this->View->pageTitle));
$this->assertEquals('test', $this->View->pageTitle);
}
/**
* Test that setting arbitrary properties still works.
*
* @return void
*/
public function testPropertySettingMagicGet() {
$this->assertFalse(isset($this->View->action));
$this->View->request->params['action'] = 'login';
$this->assertEquals('login', $this->View->action);
$this->assertTrue(isset($this->View->action));
$this->assertTrue(!empty($this->View->action));
}
}

View file

@ -762,7 +762,7 @@ class View extends Object {
case 'data':
return $this->request->{$name};
case 'action':
return isset($this->request->params['action']) ? $this->request->params['action'] : '';
return $this->request->params['action'];
case 'params':
return $this->request;
case 'output':
@ -796,7 +796,14 @@ class View extends Object {
* @return boolean
*/
public function __isset($name) {
return isset($this->{$name});
if (isset($this->{$name})) {
return true;
}
$magicGet = array('base', 'here', 'webroot', 'data', 'action', 'params', 'output');
if (in_array($name, $magicGet)) {
return $this->__get($name) !== null;
}
return false;
}
/**