mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
add testes for service builder
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class AbstractBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
public function testConstructExceptionNameEmpty()
|
||||
{
|
||||
try
|
||||
{
|
||||
$stub = $this->getMockForAbstractClass(
|
||||
"\Alchemy\Phrasea\Core\ServiceBuilder\AbstractBuilder"
|
||||
, array(
|
||||
''
|
||||
, new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag()
|
||||
, array('dependency' => 'one_dependency')
|
||||
, null
|
||||
)
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstructExceptionCreate()
|
||||
{
|
||||
try
|
||||
{
|
||||
$stub = $this->getMockForAbstractClass(
|
||||
"\Alchemy\Phrasea\Core\ServiceBuilder\AbstractBuilder"
|
||||
, array(
|
||||
'test'
|
||||
, new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag()
|
||||
, array('dependency' => 'one_dependency')
|
||||
, null
|
||||
)
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class CacheBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
public function testCreateException()
|
||||
{
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "unknow")
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\Cache::create("test", $configuration);
|
||||
$this->fail("An exception should be raised");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "array")
|
||||
);
|
||||
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\Cache::create("test", $configuration);
|
||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class LogBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
public function testCreateException()
|
||||
{
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "unknow", "options" => array())
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\Log::create("test", $configuration);
|
||||
$this->fail("An exception should be raised");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "monolog", "options" => array(
|
||||
"handler" => "rotate"
|
||||
, "filename" => "test"
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\Log::create("test", $configuration);
|
||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
||||
}
|
||||
|
||||
public function testCreateNamespace()
|
||||
{
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "normal", "options" => array(
|
||||
"handler" => "rotate"
|
||||
, "filename" => "test"
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\Log::create("test", $configuration, array(), "Doctrine");
|
||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class OrmBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
public function testCreateException()
|
||||
{
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "unknow", "options" => array())
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\Orm::create("test", $configuration);
|
||||
$this->fail("An exception should be raised");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$registry = $this->getMock("\RegistryInterface");
|
||||
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "doctrine", "options" => array(
|
||||
"debug" => false
|
||||
, "log" => "sql_logger"
|
||||
, "dbal" => "main_connexion"
|
||||
, "orm" => array(
|
||||
"cache" => array(
|
||||
"metadata" => "array_cache"
|
||||
, "query" => "array_cache"
|
||||
, "result" => "array_cache"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\Orm::create("test", $configuration, array("registry" => $registry));
|
||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class TemplateBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
public function testCreateException()
|
||||
{
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "unknow", "options" => array())
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\TemplateEngine::create("test", $configuration);
|
||||
$this->fail("An exception should be raised");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$configuration = new Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array("type" => "twig", "options" => array())
|
||||
);
|
||||
|
||||
$service = Alchemy\Phrasea\Core\ServiceBuilder\TemplateEngine::create("test", $configuration);
|
||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user