Evaluate, Test and Move the items und library/Icinga/Web to the source tree

Add test for Widget.

refs #4256
This commit is contained in:
Marius Hein 2013-06-10 12:58:12 +02:00 committed by Jannis Moßhammer
parent ccd5564a37
commit c98be3ef73
2 changed files with 35 additions and 5 deletions

View File

@ -1,8 +1,7 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Web widget class
*/
namespace Icinga\Web;
use Icinga\Exception\ProgrammingError;
@ -25,13 +24,13 @@ use Icinga\Exception\ProgrammingError;
*/
class Widget
{
/**
* Create a new widget
*
* @param string $name Widget name
* @param array $options Widget constructor options
* @param array $options Widget constructor options
*
* @throws \Icinga\Exception\ProgrammingError
* @return Icinga\Web\Widget\AbstractWidget
*/
public static function create($name, $options = array())

View File

@ -0,0 +1,31 @@
<?php
namespace Tests\Icinga\Web;
use Icinga\Web\Widget;
require_once '../../library/Icinga/Web/Widget.php';
require_once '../../library/Icinga/Web/Widget/AbstractWidget.php';
require_once '../../library/Icinga/Web/Widget/Tab.php';
require_once '../../library/Icinga/Exception/ProgrammingError.php';
class WidgetTest extends \PHPUnit_Framework_TestCase
{
public function testCreate1()
{
$widgetCreator = new Widget();
$widget = $widgetCreator->create('tab', array('name' => 'TEST'));
$this->assertInstanceOf('Icinga\Web\Widget\Tab', $widget);
}
/**
* @expectedException Icinga\Exception\ProgrammingError
* @expectedExceptionMessage There is no such widget: DOES_NOT_EXIST
*/
public function testFail1()
{
$widgetCreator = new Widget();
$widget = $widgetCreator->create('DOES_NOT_EXIST');
}
}