Skip to content
This repository has been archived by the owner on Jul 12, 2018. It is now read-only.

Commit

Permalink
Add test for Message
Browse files Browse the repository at this point in the history
  • Loading branch information
ohartl committed Mar 3, 2016
1 parent 283b4b9 commit 79d1ba2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/php/classes/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ class Message
protected $messages = array();


/**
* @codeCoverageIgnore
*/
private function __construct()
{
}


/**
* @codeCoverageIgnore
*/
private function __clone()
{
}
Expand Down
50 changes: 50 additions & 0 deletions tests/MessageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* @covers Message
*/
class MessageTest extends PHPUnit_Framework_TestCase
{

public function testSingleton()
{
$this->assertInstanceOf('Message', Message::getInstance());
}


public function testAdd()
{
Message::getInstance()->add(Message::TYPE_SUCCESS, 'lorem');

$out = Message::getInstance()->render();

$this->assertContains(Message::TYPE_SUCCESS, $out);
$this->assertContains('lorem', $out);
}


/**
* @expectedException InvalidArgumentException
*/
public function testAddRestrictTypes()
{
Message::getInstance()->add('wrong-type', 'lorem');
}


public function testAddShortcuts()
{
Message::getInstance()->fail('lorem');
$this->assertContains(Message::TYPE_FAIL, Message::getInstance()->render());

Message::getInstance()->error('lorem');
$this->assertContains(Message::TYPE_ERROR, Message::getInstance()->render());

Message::getInstance()->warning('lorem');
$this->assertContains(Message::TYPE_WARNING, Message::getInstance()->render());

Message::getInstance()->success('lorem');
$this->assertContains(Message::TYPE_SUCCESS, Message::getInstance()->render());
}

}

0 comments on commit 79d1ba2

Please sign in to comment.