Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix magic __isset()

  • Loading branch information...
commit 7badb1d252b9604cbf67d7ed81d191d87116289f 1 parent b14072a
@ceeram ceeram authored markstory committed
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
View
16 lib/Cake/Test/Case/View/ViewTest.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));
+ }
}
View
11 lib/Cake/View/View.php
@@ -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;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.