mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Fix Controller / add unitTests
This commit is contained in:
@@ -31,7 +31,7 @@ class Controller
|
||||
*/
|
||||
public static function get($type)
|
||||
{
|
||||
$classname = 'ControlProvider\\' . $type;
|
||||
$classname = __NAMESPACE__ . '\\ControlProvider\\' . $type . 'Provider';
|
||||
|
||||
if (!class_exists($classname))
|
||||
{
|
||||
|
41
lib/unitTest/Alchemy/Phrasea/Vocabulary/ControllerTest.php
Normal file
41
lib/unitTest/Alchemy/Phrasea/Vocabulary/ControllerTest.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user