Fix Controller / add unitTests

This commit is contained in:
Romain Neutron
2012-01-26 13:05:07 +01:00
parent cc083f89d0
commit f63afd1143
2 changed files with 42 additions and 1 deletions

View File

@@ -31,7 +31,7 @@ class Controller
*/ */
public static function get($type) public static function get($type)
{ {
$classname = 'ControlProvider\\' . $type; $classname = __NAMESPACE__ . '\\ControlProvider\\' . $type . 'Provider';
if (!class_exists($classname)) if (!class_exists($classname))
{ {

View File

@@ -0,0 +1,41 @@
<?php
require_once __DIR__ . '/../../../PhraseanetPHPUnitAbstract.class.inc';
/**
* Test class for Controller.
* Generated by PHPUnit on 2012-01-26 at 12:41:07.
*/
class ControllerTest extends \PhraseanetPHPUnitAbstract
{
public function testGet()
{
$provider = \Alchemy\Phrasea\Vocabulary\Controller::get('User');
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Vocabulary\\ControlProvider\\UserProvider', $provider);
try
{
$provider = \Alchemy\Phrasea\Vocabulary\Controller::get('Zebulon');
$this->fail('Should raise an exception');
}
catch(\Exception $e)
{
}
}
public function testGetAvailable()
{
$available = \Alchemy\Phrasea\Vocabulary\Controller::getAvailable();
$this->assertTrue(is_array($available));
foreach($available as $controller)
{
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Vocabulary\\ControlProvider\\ControlProviderInterface', $controller);
}
}
}