Skip to content

Commit

Permalink
Make use of built-in message template of MissingElementException
Browse files Browse the repository at this point in the history
  • Loading branch information
ravage84 committed Dec 12, 2016
1 parent 520926f commit 1feaa49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/View/View.php
Expand Up @@ -505,9 +505,7 @@ public function element($name, array $data = [], array $options = [])
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]);
}
}

Expand Down
8 changes: 5 additions & 3 deletions tests/TestCase/View/ViewTest.php
Expand Up @@ -897,9 +897,10 @@ public function testPrefixElement()
}

/**
* 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()
Expand All @@ -908,12 +909,13 @@ public function testElementInexistent()
}

/**
* 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');
}
Expand Down

0 comments on commit 1feaa49

Please sign in to comment.