2012-04-13 14:11:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Nelmio\ApiDocBundle\Tests;
|
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
2012-05-23 00:02:38 +02:00
|
|
|
use Symfony\Component\HttpKernel\Util\Filesystem;
|
2012-04-13 14:11:54 +02:00
|
|
|
use Symfony\Component\HttpKernel\Kernel;
|
|
|
|
|
|
|
|
abstract class WebTestCase extends BaseWebTestCase
|
|
|
|
{
|
2012-04-19 21:23:59 +02:00
|
|
|
protected function deleteTmpDir()
|
2012-04-13 14:11:54 +02:00
|
|
|
{
|
2012-04-19 21:23:59 +02:00
|
|
|
if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION)) {
|
2012-04-13 14:11:54 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$fs = new Filesystem();
|
|
|
|
$fs->remove($dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getContainer(array $options = array())
|
|
|
|
{
|
|
|
|
if (!static::$kernel) {
|
|
|
|
static::$kernel = static::createKernel($options);
|
|
|
|
}
|
|
|
|
static::$kernel->boot();
|
|
|
|
|
|
|
|
return static::$kernel->getContainer();
|
|
|
|
}
|
|
|
|
|
2012-05-23 00:33:01 +02:00
|
|
|
protected static function getKernelClass()
|
2012-04-13 14:11:54 +02:00
|
|
|
{
|
|
|
|
require_once __DIR__.'/Fixtures/app/AppKernel.php';
|
|
|
|
|
|
|
|
return 'Nelmio\ApiDocBundle\Tests\Functional\AppKernel';
|
|
|
|
}
|
|
|
|
|
2012-05-23 00:33:01 +02:00
|
|
|
protected static function createKernel(array $options = array())
|
2012-04-13 14:11:54 +02:00
|
|
|
{
|
|
|
|
$class = self::getKernelClass();
|
|
|
|
|
|
|
|
return new $class(
|
|
|
|
'default',
|
|
|
|
isset($options['debug']) ? $options['debug'] : true
|
|
|
|
);
|
|
|
|
}
|
2012-04-19 21:23:59 +02:00
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->deleteTmpDir();
|
|
|
|
}
|
2012-04-13 14:11:54 +02:00
|
|
|
}
|