mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 07:41:43 +03:00
Speedup tests
This commit is contained in:
parent
e66fb209b5
commit
4b72190f4d
@ -73,14 +73,12 @@ class CachingApiDocExtractor extends ApiDocExtractor
|
||||
{
|
||||
$cache = $this->getViewCache($view);
|
||||
|
||||
if ($cache->isFresh() === false) {
|
||||
|
||||
if (!$cache->isFresh()) {
|
||||
$resources = array();
|
||||
|
||||
foreach ($this->getRoutes() as $route) {
|
||||
if ( null !== ($method = $this->getReflectionMethod($route->getDefault('_controller')))
|
||||
&& null !== ($annotation = $this->reader->getMethodAnnotation($method, self::ANNOTATION_CLASS))) {
|
||||
$file = $method->getDeclaringClass()->getFileName();
|
||||
$file = $method->getDeclaringClass()->getFileName();
|
||||
$resources[] = new FileResource($file);
|
||||
}
|
||||
}
|
||||
@ -94,8 +92,14 @@ class CachingApiDocExtractor extends ApiDocExtractor
|
||||
return $data;
|
||||
}
|
||||
|
||||
return unserialize(file_get_contents($cache));
|
||||
// For BC
|
||||
if (method_exists($cache, 'getPath')) {
|
||||
$cachePath = $cache->getPath();
|
||||
} else {
|
||||
$cachePath = (string) $cache;
|
||||
}
|
||||
|
||||
return unserialize(file_get_contents($cachePath));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,8 +67,6 @@ class CachingApiDocExtractorTest extends WebTestCase
|
||||
|
||||
$expectedViewCacheFile = $cacheFile.'.'.$view;
|
||||
|
||||
$this->assertFileNotExists($expectedViewCacheFile);
|
||||
|
||||
set_error_handler(array($this, 'handleDeprecation'));
|
||||
$data = $extractor->all($view);
|
||||
|
||||
|
@ -17,10 +17,10 @@ use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
abstract class WebTestCase extends BaseWebTestCase
|
||||
{
|
||||
public static $container;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->deleteTmpDir();
|
||||
|
||||
parent::setUp();
|
||||
|
||||
if (version_compare(Kernel::VERSION, '2.2.0', '<')) {
|
||||
@ -28,16 +28,6 @@ abstract class WebTestCase extends BaseWebTestCase
|
||||
}
|
||||
}
|
||||
|
||||
protected function deleteTmpDir()
|
||||
{
|
||||
if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fs = new Filesystem();
|
||||
$fs->remove($dir);
|
||||
}
|
||||
|
||||
public static function handleDeprecation($errorNumber, $message, $file, $line, $context)
|
||||
{
|
||||
if ($errorNumber & E_USER_DEPRECATED) {
|
||||
@ -49,12 +39,17 @@ abstract class WebTestCase extends BaseWebTestCase
|
||||
|
||||
protected function getContainer(array $options = array())
|
||||
{
|
||||
if (!static::$kernel) {
|
||||
static::$kernel = static::createKernel($options);
|
||||
}
|
||||
static::$kernel->boot();
|
||||
if (!static::$container) {
|
||||
if (!static::$kernel) {
|
||||
static::$kernel = static::createKernel($options);
|
||||
}
|
||||
|
||||
return static::$kernel->getContainer();
|
||||
static::$kernel->boot();
|
||||
|
||||
static::$container = static::$kernel->getContainer();
|
||||
}
|
||||
|
||||
return static::$container;
|
||||
}
|
||||
|
||||
protected static function getKernelClass()
|
||||
@ -73,10 +68,4 @@ abstract class WebTestCase extends BaseWebTestCase
|
||||
isset($options['debug']) ? $options['debug'] : true
|
||||
);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->deleteTmpDir();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user