/**
  * Create new ErrorMessageException.
  *
  * @param  mixed  $messages
  * @param  int  $code
  * @param  Exception  $previous
  * @return void
  */
 public function __construct($messages, $code = 0, Exception $previous = null)
 {
     // Make sure we're working with a MessageBag
     if (!$messages instanceof MessageProviderInterface) {
         $messages = new MessageBag((array) $messages);
     }
     $this->messages = $messages->getMessageBag();
     $this->messages->setFormat(':message');
     parent::__construct('', $code, $previous);
 }
 public function testFormatIsRespected()
 {
     $container = new MessageBag();
     $container->setFormat('<p>:message</p>');
     $container->add('foo', 'bar');
     $container->add('boom', 'baz');
     $this->assertEquals('<p>bar</p>', $container->first('foo'));
     $this->assertEquals(array('<p>bar</p>'), $container->get('foo'));
     $this->assertEquals(array('<p>bar</p>', '<p>baz</p>'), $container->all());
     $this->assertEquals('bar', $container->first('foo', ':message'));
     $this->assertEquals(array('bar'), $container->get('foo', ':message'));
     $this->assertEquals(array('bar', 'baz'), $container->all(':message'));
 }