Commit df27e9eb authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Aide de vue Messenger : tests unitaires manquants.

parent 87fb7d4d
<?php
namespace UnicaenApp\View\Helper;
use Exception;
use UnicaenApp\Exception;
use UnicaenApp\View\Helper\Messenger;
use Zend\View\Helper\AbstractHelper;
......@@ -66,14 +66,7 @@ class Messenger extends AbstractHelper
*/
public function __toString()
{
try {
return $this->render();
}
catch (Exception $e) {
$msg = get_class($e) . ': ' . $e->getMessage();
trigger_error($msg, E_USER_ERROR);
return '';
}
return $this->render();
}
/**
......@@ -238,7 +231,7 @@ class Messenger extends AbstractHelper
public function getTemplate($severity, $containerId = null)
{
if (!isset($this->uiClasses[$severity])) {
throw new Unicaen_Exception ("Sévérité inconnue: " . $severity);
throw new Exception("Sévérité inconnue: " . $severity);
}
$innerTemplate = $this->containerInnerTemplate ?: '%s';
......
......@@ -108,7 +108,7 @@ class MessengerText extends AbstractTest
$this->assertEquals(array('info' => array($message)), $this->helper->getMessages());
}
public function testcanAddMessage()
public function testCanAddMessage()
{
$this->helper->setMessages(array(
'info' => "Information message.",
......@@ -212,6 +212,14 @@ class MessengerText extends AbstractTest
$this->assertEquals($this->getExpected($expectedScript), $markup);
}
/**
* @expectedException \UnicaenApp\Exception
*/
public function testGettingTemplateForUnknownSeverityThrowsException()
{
$this->helper->getTemplate('unknown');
}
public function testCanCustomizeMarkupTemplate()
{
$this->helper->addMessage("Information message.")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment