Skip to content
Permalink
Browse files

fix magic __isset()

  • Loading branch information...
ceeram authored and markstory committed Jan 12, 2012
1 parent b14072a commit 7badb1d252b9604cbf67d7ed81d191d87116289f
Showing with 24 additions and 3 deletions.
  1. +15 −1 lib/Cake/Test/Case/View/ViewTest.php
  2. +9 −2 lib/Cake/View/View.php
@@ -677,7 +677,7 @@ public function testHelperCallbackTriggering() {
$this->attributeEqualTo('_subject', $View)
)
);
$View->Helpers->expects($this->at(4))->method('trigger')
->with(
$this->logicalAnd(
@@ -1246,6 +1246,20 @@ public function testPropertySetting() {
$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));
}
}
@@ -762,7 +762,7 @@ public function __get($name) {
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 @@ public function __set($name, $value) {
* @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;
}
/**

0 comments on commit 7badb1d

Please sign in to comment.
You can’t perform that action at this time.