From 4e49b63140ef78712e26922269ae80b052bdf0df Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 8 Jun 2014 14:51:57 -0400 Subject: [PATCH] Raise exceptions on missing elements. We should be avoiding trigger_error() in Cake3, and instead use exceptions. --- src/View/Error/MissingElementException.php | 30 ++++++++++++++++++++++ src/View/View.php | 5 ++-- tests/TestCase/View/ViewTest.php | 15 ++--------- 3 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 src/View/Error/MissingElementException.php diff --git a/src/View/Error/MissingElementException.php b/src/View/Error/MissingElementException.php new file mode 100644 index 00000000000..170370b277d --- /dev/null +++ b/src/View/Error/MissingElementException.php @@ -0,0 +1,30 @@ +_ext; - trigger_error(sprintf('Element Not Found: %s', $file), E_USER_NOTICE); + throw new Error\MissingElementException($file); } } diff --git a/tests/TestCase/View/ViewTest.php b/tests/TestCase/View/ViewTest.php index de97f945e90..99fe50f4522 100644 --- a/tests/TestCase/View/ViewTest.php +++ b/tests/TestCase/View/ViewTest.php @@ -98,17 +98,6 @@ public function index() { */ class TestThemeView extends View { -/** - * renderElement method - * - * @param string $name Element name. - * @param array $params Params list. - * @return string The given name - */ - public function renderElement($name, $params = array()) { - return $name; - } - /** * getViewFileName method * @@ -653,7 +642,7 @@ public function testElement() { /** * Test elementInexistent method * - * @expectedException PHPUnit_Framework_Error_Notice + * @expectedException Cake\View\Error\MissingElementException * @return void */ public function testElementInexistent() { @@ -663,7 +652,7 @@ public function testElementInexistent() { /** * Test elementInexistent3 method * - * @expectedException PHPUnit_Framework_Error_Notice + * @expectedException Cake\View\Error\MissingElementException * @return void */ public function testElementInexistent3() {