Browse Source

Make use of built-in message template of MissingElementException

Marc Würth 9 years ago
parent
commit
1feaa491e0
2 changed files with 6 additions and 6 deletions
  1. 1 3
      src/View/View.php
  2. 5 3
      tests/TestCase/View/ViewTest.php

+ 1 - 3
src/View/View.php

@@ -505,9 +505,7 @@ class View implements EventDispatcherInterface
             list ($plugin, $name) = pluginSplit($name, true);
             $name = str_replace('/', DIRECTORY_SEPARATOR, $name);
             $file = $plugin . 'Element' . DIRECTORY_SEPARATOR . $name . $this->_ext;
-            throw new MissingElementException(
-                sprintf('Element file "%s" is missing', $file)
-            );
+            throw new MissingElementException([$file]);
         }
     }
 

+ 5 - 3
tests/TestCase/View/ViewTest.php

@@ -897,9 +897,10 @@ class ViewTest extends TestCase
     }
 
     /**
-     * Test elementInexistent method
+     * Test loading inexistent view element
      *
      * @expectedException \Cake\View\Exception\MissingElementException
+     * @expectedExceptionMessage Element file "Element\non_existent_element.ctp" is missing
      * @return void
      */
     public function testElementInexistent()
@@ -908,12 +909,13 @@ class ViewTest extends TestCase
     }
 
     /**
-     * Test elementInexistent3 method
+     * Test loading inexistent plugin view element
      *
      * @expectedException \Cake\View\Exception\MissingElementException
+     * @expectedExceptionMessage Element file "test_plugin.Element\plugin_element.ctp" is missing
      * @return void
      */
-    public function testElementInexistent3()
+    public function testElementInexistentPluginElement()
     {
         $this->View->element('test_plugin.plugin_element');
     }