Throw an exception when a view extends itself.

This commit is contained in:
mark_story 2011-12-23 23:56:48 -05:00 committed by Mark Story
parent 047e93e285
commit 70981d05ca
3 changed files with 16 additions and 0 deletions

View file

@ -1147,6 +1147,17 @@ TEXT;
$this->assertEquals($expected, $content);
}
/**
* Make sure that extending the current view with itself causes an exception
*
* @expectedException LogicException
* @return void
*/
public function testExtendSelf() {
$this->View->layout = false;
$this->View->render('extend_self');
}
/**
* Test extend() in an element and a view.
*

View file

@ -0,0 +1,2 @@
<?php $this->extend('extend_self'); ?>
To infinifty and beyond.

View file

@ -633,6 +633,9 @@ class View extends Object {
break;
}
if ($parent == $this->_current) {
throw new LogicException(__d('cake_dev', 'You cannot have views extend themselves.'));
}
$this->_parents[$this->_current] = $parent;
}