mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 06:44:33 +02:00
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:
parent
ccd5564a37
commit
c98be3ef73
@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
/**
|
|
||||||
* Web widget class
|
|
||||||
*/
|
|
||||||
namespace Icinga\Web;
|
namespace Icinga\Web;
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
@ -25,13 +24,13 @@ use Icinga\Exception\ProgrammingError;
|
|||||||
*/
|
*/
|
||||||
class Widget
|
class Widget
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new widget
|
* Create a new widget
|
||||||
*
|
*
|
||||||
* @param string $name Widget name
|
* @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
|
* @return Icinga\Web\Widget\AbstractWidget
|
||||||
*/
|
*/
|
||||||
public static function create($name, $options = array())
|
public static function create($name, $options = array())
|
||||||
|
31
test/php/library/Icinga/Web/WidgetTest.php
Normal file
31
test/php/library/Icinga/Web/WidgetTest.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user