mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
Merge pull request #1322 from bburnichon/feature/task-manager-start
task manager start
This commit is contained in:
150
composer.json
150
composer.json
@@ -1,106 +1,100 @@
|
||||
{
|
||||
"name" : "phraseanet/phraseanet",
|
||||
"description" : "Phraseanet",
|
||||
"license" : "GPL-3.0",
|
||||
"config": {
|
||||
"bin-dir" : "bin/"
|
||||
"name": "phraseanet/phraseanet",
|
||||
"description": "Phraseanet",
|
||||
"license": "GPL-3.0",
|
||||
"config": {
|
||||
"bin-dir": "bin/"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/alchemy-fr/tcpdf-clone"
|
||||
"url": "https://github.com/alchemy-fr/tcpdf-clone"
|
||||
},
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/romainneutron/ProcessManager.git"
|
||||
"url": "https://github.com/romainneutron/ProcessManager.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/alchemy-fr/imagine"
|
||||
"url": "https://github.com/alchemy-fr/imagine"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/alchemy-fr/phpexiftool"
|
||||
"url": "https://github.com/alchemy-fr/phpexiftool"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/alchemy-fr/JMSTranslationBundle"
|
||||
"url": "https://github.com/alchemy-fr/JMSTranslationBundle"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php" : ">=5.5",
|
||||
"alchemy/oauth2php" : "1.0.0",
|
||||
"alchemy/phlickr" : "0.2.9",
|
||||
"alchemy/task-manager" : "2.0.x-dev@dev",
|
||||
"alchemy/zippy" : "0.2.x-dev@dev",
|
||||
"dailymotion/sdk" : "~1.5",
|
||||
"data-uri/data-uri" : "~0.1.0",
|
||||
"doctrine/orm" : "~2.4.0",
|
||||
"doctrine/dbal" : "~2.4.0",
|
||||
"elasticsearch/elasticsearch" : "~1.0",
|
||||
"facebook/php-sdk" : "~3.0",
|
||||
"gedmo/doctrine-extensions" : "~2.3.0",
|
||||
"alchemy/google-plus-api-client" : "~0.6.2",
|
||||
"alchemy/geonames-api-consumer" : "~0.1.0",
|
||||
"goodby/csv" : "dev-master",
|
||||
"guzzle/guzzle" : "~3.0",
|
||||
"imagine/imagine" : "dev-alchemy-0.6.2 as 0.6.2",
|
||||
"igorw/get-in" : "~1.0",
|
||||
"ircmaxell/random-lib" : "~1.0",
|
||||
"jms/serializer" : "~0.10",
|
||||
"jms/translation-bundle" : "dev-master as 1.1.0",
|
||||
"justinrainbow/json-schema" : "~1.3",
|
||||
"mediavorus/mediavorus" : "~0.4.0",
|
||||
"media-alchemyst/media-alchemyst" : "~0.4",
|
||||
"monolog/monolog" : "~1.3",
|
||||
"mrclay/minify" : "~2.1.6",
|
||||
"neutron/process-manager" : "2.0.x-dev@dev",
|
||||
"neutron/silex-imagine-provider" : "~0.1.0",
|
||||
"neutron/silex-filesystem-provider": "~1.0",
|
||||
"neutron/sphinxsearch-api" : "~2.0.6",
|
||||
"neutron/recaptcha" : "~0.1.0",
|
||||
"neutron/temporary-filesystem" : "~2.1",
|
||||
"php-ffmpeg/php-ffmpeg" : "~0.5.0",
|
||||
"php-xpdf/php-xpdf" : "~0.2.1",
|
||||
"phpexiftool/phpexiftool" : "dev-0.4.1-mwg-metadata-copy as 0.4.1",
|
||||
"rhumsaa/uuid" : "~2.7",
|
||||
"silex/silex" : "1.1.x-dev@dev",
|
||||
"silex/web-profiler" : "~1.0.0@dev",
|
||||
"sorien/silex-dbal-profiler" : "~1.0.0",
|
||||
"swiftmailer/swiftmailer" : "~5.3.0",
|
||||
"symfony/symfony" : "~2.4",
|
||||
"alchemy-fr/tcpdf-clone" : "~6.0",
|
||||
"themattharris/tmhoauth" : "~0.7",
|
||||
"twig/twig" : "~1.14, >=1.14.2",
|
||||
"twig/extensions" : "~1.0",
|
||||
"vierbergenlars/php-semver" : "~2.1",
|
||||
"zend/gdata" : "~1.12.1",
|
||||
"doctrine/migrations" : "1.0.x-dev@dev",
|
||||
"willdurand/negotiation" : "~1.3",
|
||||
"hoa/compiler": "2.14.09.23",
|
||||
"dflydev/doctrine-orm-service-provider" : "~1.0",
|
||||
"roave/security-advisories": "dev-master"
|
||||
"require": {
|
||||
"php": ">=5.5",
|
||||
|
||||
"alchemy-fr/tcpdf-clone": "~6.0",
|
||||
"alchemy/geonames-api-consumer": "~0.1.0",
|
||||
"alchemy/google-plus-api-client": "~0.6.2",
|
||||
"alchemy/oauth2php": "1.0.0",
|
||||
"alchemy/phlickr": "0.2.9",
|
||||
"alchemy/task-manager": "2.0.x-dev@dev",
|
||||
"alchemy/zippy": "0.2.x-dev@dev",
|
||||
"dailymotion/sdk": "~1.5",
|
||||
"data-uri/data-uri": "~0.1.0",
|
||||
"dflydev/doctrine-orm-service-provider": "~1.0",
|
||||
"doctrine/dbal": "~2.4.0",
|
||||
"doctrine/migrations": "1.0.x-dev@dev",
|
||||
"doctrine/orm": "~2.4.0",
|
||||
"elasticsearch/elasticsearch": "~1.0",
|
||||
"facebook/php-sdk": "~3.0",
|
||||
"gedmo/doctrine-extensions": "~2.3.0",
|
||||
"goodby/csv": "dev-master",
|
||||
"guzzle/guzzle": "~3.0",
|
||||
"hoa/compiler": "2.14.09.23",
|
||||
"igorw/get-in": "~1.0",
|
||||
"imagine/imagine": "dev-alchemy-0.6.2 as 0.6.2",
|
||||
"ircmaxell/random-lib": "~1.0",
|
||||
"jms/serializer": "~0.10",
|
||||
"jms/translation-bundle": "dev-master as 1.1.0",
|
||||
"justinrainbow/json-schema": "~1.3",
|
||||
"media-alchemyst/media-alchemyst": "~0.4",
|
||||
"mediavorus/mediavorus": "~0.4.0",
|
||||
"monolog/monolog": "~1.3",
|
||||
"mrclay/minify": "~2.1.6",
|
||||
"neutron/process-manager": "2.0.x-dev@dev",
|
||||
"neutron/recaptcha": "~0.1.0",
|
||||
"neutron/silex-filesystem-provider": "~1.0",
|
||||
"neutron/silex-imagine-provider": "~0.1.0",
|
||||
"neutron/sphinxsearch-api": "~2.0.6",
|
||||
"neutron/temporary-filesystem": "~2.1",
|
||||
"php-ffmpeg/php-ffmpeg": "~0.5.0",
|
||||
"php-xpdf/php-xpdf": "~0.2.1",
|
||||
"phpexiftool/phpexiftool": "dev-0.4.1-mwg-metadata-copy as 0.4.1",
|
||||
"rhumsaa/uuid": "~2.7",
|
||||
"roave/security-advisories": "dev-master",
|
||||
"silex/silex": "~1.2",
|
||||
"silex/web-profiler": "~1.0",
|
||||
"sorien/silex-dbal-profiler": "~1.0.0",
|
||||
"swiftmailer/swiftmailer": "~5.3.0",
|
||||
"symfony/symfony": "~2.4",
|
||||
"themattharris/tmhoauth": "~0.7",
|
||||
"twig/extensions": "~1.0",
|
||||
"twig/twig": "~1.14, >=1.14.2",
|
||||
"vierbergenlars/php-semver": "~2.1",
|
||||
"willdurand/negotiation": "~1.3",
|
||||
"zend/gdata": "~1.12.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit" : "~4.5",
|
||||
"behat/behat" : "2.5.x-dev@dev",
|
||||
"behat/gherkin" : "2.3.x-dev@dev",
|
||||
"behat/mink" : "~1.4",
|
||||
"behat/mink-extension" : "~1.0",
|
||||
"behat/mink-goutte-driver" : "~1.0",
|
||||
"behat/mink-selenium2-driver" : "~1.0",
|
||||
"fabpot/goutte" : "~1.0",
|
||||
"hoa/dispatcher": "0.14.09.23",
|
||||
"hoa/console": "2.14.09.23"
|
||||
"require-dev": {
|
||||
"hoa/console": "2.14.09.23",
|
||||
"hoa/dispatcher": "0.14.09.23",
|
||||
"phpunit/phpunit": "~4.5"
|
||||
},
|
||||
"autoload": {
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"" : "lib/classes",
|
||||
"Alchemy" : "lib"
|
||||
"Alchemy\\": "lib",
|
||||
"": "lib/classes"
|
||||
}
|
||||
},
|
||||
"include-path": ["vendor/zend/gdata/library"],
|
||||
"extra": {
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.9.x-dev"
|
||||
}
|
||||
|
1296
composer.lock
generated
1296
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Command\Task;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Alchemy\Phrasea\TaskManager\TaskManagerStatus;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Command\Task;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Alchemy\Phrasea\TaskManager\TaskManagerStatus;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
@@ -11,11 +11,10 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Task;
|
||||
|
||||
use Alchemy\TaskManager\TaskManager;
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Alchemy\TaskManager\Event\TaskManagerSubscriber\LockFileSubscriber;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Logger;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
@@ -12,10 +12,11 @@
|
||||
namespace Alchemy\Phrasea\Command\Task;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Alchemy\Phrasea\Model\Entities\Task;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class SchedulerState extends Command
|
||||
{
|
||||
|
@@ -12,13 +12,16 @@
|
||||
namespace Alchemy\Phrasea\Controller\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Alchemy\Phrasea\Form\TaskForm;
|
||||
use Alchemy\Phrasea\Model\Entities\Task;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Alchemy\Phrasea\Exception\XMLParseErrorException;
|
||||
use Alchemy\Phrasea\TaskManager\LiveInformation;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class TaskManager implements ControllerProviderInterface
|
||||
{
|
||||
@@ -126,6 +129,25 @@ class TaskManager implements ControllerProviderInterface
|
||||
{
|
||||
$app['task-manager.status']->start();
|
||||
|
||||
$cmdLine = sprintf(
|
||||
'%s %s %s',
|
||||
$app['conf']->get(['main', 'binaries', 'php_binary']),
|
||||
realpath(__DIR__ . '/../../../../../bin/console'),
|
||||
'task-manager:scheduler:run'
|
||||
);
|
||||
|
||||
/** @var EventDispatcherInterface $dispatcher */
|
||||
$dispatcher = $app['dispatcher'];
|
||||
$dispatcher->addListener(KernelEvents::TERMINATE, function () use ($cmdLine) {
|
||||
$process = new Process($cmdLine);
|
||||
$process->setTimeout(0);
|
||||
$process->disableOutput();
|
||||
set_time_limit(0);
|
||||
ignore_user_abort(true);
|
||||
|
||||
$process->run();
|
||||
}, -1000);
|
||||
|
||||
return $app->redirectPath('admin_tasks_list');
|
||||
}
|
||||
|
||||
@@ -133,6 +155,17 @@ class TaskManager implements ControllerProviderInterface
|
||||
{
|
||||
$app['task-manager.status']->stop();
|
||||
|
||||
/** @var LiveInformation $info */
|
||||
$info = $app['task-manager.live-information'];
|
||||
$data = $info->getManager();
|
||||
if (null !== $pid = $data['process-id']) {
|
||||
if (substr(php_uname(), 0, 7) == "Windows"){
|
||||
exec(sprintf('TaskKill /PID %d', $pid));
|
||||
} else {
|
||||
exec(sprintf('kill %d', $pid));
|
||||
}
|
||||
}
|
||||
|
||||
return $app->redirectPath('admin_tasks_list');
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,9 @@ namespace Alchemy\Phrasea\Core\Provider;
|
||||
use Alchemy\Phrasea\Core\Configuration\SessionHandlerFactory;
|
||||
use Silex\Application;
|
||||
use Silex\ServiceProviderInterface;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
class SessionHandlerServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
@@ -27,10 +30,24 @@ class SessionHandlerServiceProvider implements ServiceProviderInterface
|
||||
});
|
||||
}
|
||||
|
||||
public function onKernelResponse(FilterResponseEvent $event)
|
||||
{
|
||||
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$session = $event->getRequest()->getSession();
|
||||
if ($session && $session->isStarted()) {
|
||||
$session->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function boot(Application $app)
|
||||
{
|
||||
// Priority should be lower than test session mock listener
|
||||
$app['dispatcher']->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'), -129);
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ class NginxMode extends AbstractServerMode implements ModeInterface
|
||||
$xAccelMapping = [];
|
||||
|
||||
foreach ($this->mapping as $entry) {
|
||||
$xAccelMapping[] = sprintf('%s=%s', $entry['mount-point'], $entry['directory']);
|
||||
$xAccelMapping[] = sprintf('%s=%s', $entry['directory'], $entry['mount-point']);
|
||||
}
|
||||
|
||||
if (count($xAccelMapping) > 0 ) {
|
||||
|
@@ -22,11 +22,13 @@
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<blacklist>
|
||||
<directory>lib/vendor</directory>
|
||||
<directory>tests</directory>
|
||||
<directory>vendor</directory>
|
||||
</blacklist>
|
||||
<blacklist>
|
||||
<directory>tests</directory>
|
||||
<directory>vendor</directory>
|
||||
</blacklist>
|
||||
<whitelist>
|
||||
<directory suffix=".php">lib</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<!--<listeners>-->
|
||||
|
@@ -4,6 +4,8 @@ namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Model\Entities\Task;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
class TaskManagerTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
@@ -63,6 +65,11 @@ class TaskManagerTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
->getMock();
|
||||
self::$DI['app']['task-manager.status']->expects($this->once())
|
||||
->method('start');
|
||||
// Prevent actual start of process scheduler
|
||||
self::$DI['app']['dispatcher']->addListener(KernelEvents::TERMINATE, function (PostResponseEvent $event) {
|
||||
$event->stopPropagation();
|
||||
}, -999);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/task-manager/scheduler/start');
|
||||
$this->assertEquals(302, self::$DI['client']->getResponse()->getStatusCode());
|
||||
$this->assertEquals('/admin/task-manager/tasks', self::$DI['client']->getResponse()->headers->get('location'));
|
||||
|
@@ -102,7 +102,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertTrue($record->get_thumbnail()->is_physically_present());
|
||||
$fields = $record->get_caption()->get_fields(['FileName']);
|
||||
$field = array_pop($fields);
|
||||
$this->assertEquals($field->get_serialized_values(), 'KIKOO');
|
||||
$this->assertEquals('KIKOO.JPG', $field->get_serialized_values());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertTrue($client->getResponse()->isRedirect());
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('location'));
|
||||
$this->assertEquals('/login?redirect=..%2Fprod', $client->getResponse()->headers->get('location'));
|
||||
$this->assertRegExp('#/login\?redirect=..(?:%2F|/)prod#', $client->getResponse()->headers->get('location'));
|
||||
}
|
||||
|
||||
public function testEndSessionXmlXhttpRequest()
|
||||
@@ -132,7 +132,7 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertTrue($client->getResponse()->isRedirect());
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('location'));
|
||||
$this->assertEquals('/login?redirect=..%2Fprod', $client->getResponse()->headers->get('location'));
|
||||
$this->assertRegExp('#/login\?redirect=..(?:%2F|/)prod#', $client->getResponse()->headers->get('location'));
|
||||
}
|
||||
|
||||
public function testEndSessionAuthenticatedWithOutdatedIdleXmlHttpRequest()
|
||||
|
@@ -5,17 +5,31 @@ namespace Alchemy\Tests\Phrasea\Core\Provider;
|
||||
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
||||
use Alchemy\Phrasea\Core\Provider\SessionHandlerServiceProvider;
|
||||
use Alchemy\Tests\Phrasea\MockArrayConf;
|
||||
use Silex\Application as SilexApp;
|
||||
use Silex\Application;
|
||||
use Silex\Provider\SessionServiceProvider;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
class SessionHandlerServiceProviderTest extends \PhraseanetTestCase
|
||||
class SessionHandlerServiceProviderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideVariousConfs
|
||||
*/
|
||||
public function testWithVariousConf($sessionConf, $expectedInstance, $method = null, $options = null, $mock = null)
|
||||
/** @var SessionHandlerServiceProvider */
|
||||
private $sut;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$app = new SilexApp();
|
||||
$this->sut = new SessionHandlerServiceProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideVariousConfigurations
|
||||
*/
|
||||
public function testWithVariousConfigurations($sessionConf, $expectedInstance, $method = null, $options = null, $mock = null)
|
||||
{
|
||||
$app = new Application();
|
||||
$app['root.path'] = __DIR__ . '/../../../../../..';
|
||||
$app->register(new SessionServiceProvider());
|
||||
$app->register(new SessionHandlerServiceProvider());
|
||||
@@ -35,60 +49,9 @@ class SessionHandlerServiceProviderTest extends \PhraseanetTestCase
|
||||
$this->assertInstanceOf($expectedInstance, $handler);
|
||||
}
|
||||
|
||||
public function provideVariousConfs()
|
||||
public function provideVariousConfigurations()
|
||||
{
|
||||
$memcache = $this->getMockBuilder('Memcache')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
@$memcached = $this->getMockBuilder('Memcached')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$redis = $this->getMockBuilder('Redis')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
return [
|
||||
[
|
||||
[
|
||||
'type' => 'memcache',
|
||||
'options' => [
|
||||
'host' => 'localhost',
|
||||
'port' => '11211',
|
||||
]
|
||||
],
|
||||
'Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler',
|
||||
'getMemcacheConnection',
|
||||
['host' => 'localhost', 'port' => 11211],
|
||||
$memcache
|
||||
],
|
||||
[
|
||||
[
|
||||
'type' => 'memcached',
|
||||
'options' => [
|
||||
'host' => 'localhost',
|
||||
'port' => '11211',
|
||||
]
|
||||
],
|
||||
'Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler',
|
||||
'getMemcachedConnection',
|
||||
['host' => 'localhost', 'port' => 11211],
|
||||
$memcached
|
||||
],
|
||||
[
|
||||
[
|
||||
'type' => 'redis',
|
||||
'options' => [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '6379',
|
||||
]
|
||||
],
|
||||
'Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler',
|
||||
'getRedisConnection',
|
||||
['host' => '127.0.0.1', 'port' => 6379],
|
||||
$redis
|
||||
],
|
||||
$configurations = [
|
||||
[
|
||||
[
|
||||
'main' => [
|
||||
@@ -100,5 +63,129 @@ class SessionHandlerServiceProviderTest extends \PhraseanetTestCase
|
||||
'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler'
|
||||
]
|
||||
];
|
||||
|
||||
if (class_exists('Memcache')) {
|
||||
$memcache = $this->getMockBuilder('Memcache')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$configurations[] = [
|
||||
[
|
||||
'type' => 'memcache',
|
||||
'options' => [
|
||||
'host' => 'localhost',
|
||||
'port' => '11211',
|
||||
]
|
||||
],
|
||||
'Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler',
|
||||
'getMemcacheConnection',
|
||||
['host' => 'localhost', 'port' => 11211],
|
||||
$memcache
|
||||
];
|
||||
}
|
||||
|
||||
if (class_exists('Memcached')) {
|
||||
// Error suppressor due to Memcached having now obsolete by reference declarations
|
||||
@$memcached = $this->getMockBuilder('Memcached')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$configurations[] = [
|
||||
[
|
||||
'type' => 'memcached',
|
||||
'options' => [
|
||||
'host' => 'localhost',
|
||||
'port' => '11211',
|
||||
]
|
||||
],
|
||||
'Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler',
|
||||
'getMemcachedConnection',
|
||||
['host' => 'localhost', 'port' => 11211],
|
||||
$memcached
|
||||
];
|
||||
}
|
||||
|
||||
if (class_exists('Redis')) {
|
||||
$redis = $this->getMockBuilder('Redis')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$configurations[] = [
|
||||
[
|
||||
'type' => 'redis',
|
||||
'options' => [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '6379',
|
||||
]
|
||||
],
|
||||
'Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler',
|
||||
'getRedisConnection',
|
||||
['host' => '127.0.0.1', 'port' => 6379],
|
||||
$redis
|
||||
];
|
||||
}
|
||||
|
||||
return $configurations;
|
||||
}
|
||||
|
||||
public function testItIgnoresSubRequests()
|
||||
{
|
||||
$event = $this->getMockBuilder(FilterResponseEvent::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$event->expects($this->once())
|
||||
->method('getRequestType')
|
||||
->willReturn(HttpKernelInterface::SUB_REQUEST)
|
||||
;
|
||||
|
||||
$this->sut->onKernelResponse($event);
|
||||
}
|
||||
|
||||
public function testItSavesSessionAtKernelResponseEvent()
|
||||
{
|
||||
$session = $this->getMock(SessionInterface::class);
|
||||
$session
|
||||
->expects($this->once())
|
||||
->method('isStarted')
|
||||
->willReturn(true)
|
||||
;
|
||||
$session
|
||||
->expects($this->once())
|
||||
->method('save')
|
||||
;
|
||||
|
||||
$request = new Request();
|
||||
$request->setSession($session);
|
||||
|
||||
$event = $this->getMockBuilder(FilterResponseEvent::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$event->expects($this->once())
|
||||
->method('getRequestType')
|
||||
->willReturn(HttpKernelInterface::MASTER_REQUEST)
|
||||
;
|
||||
$event
|
||||
->expects($this->once())
|
||||
->method('getRequest')
|
||||
->willReturn($request)
|
||||
;
|
||||
|
||||
$this->sut->onKernelResponse($event);
|
||||
}
|
||||
|
||||
public function testItAddsFilterResponseAtBoot()
|
||||
{
|
||||
$dispatcher = $this->getMock(EventDispatcherInterface::class);
|
||||
$dispatcher
|
||||
->expects($this->once())
|
||||
->method('addListener')
|
||||
->with(KernelEvents::RESPONSE, [$this->sut, 'onKernelResponse'], -129);
|
||||
|
||||
$app = new Application();
|
||||
$app['dispatcher'] = $dispatcher;
|
||||
|
||||
$this->sut->boot($app);
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCase
|
||||
|
||||
$response = $this->factory->deliverFile(__DIR__ . '/../../../../files/cestlafete.jpg');
|
||||
|
||||
$this->assertInstanceOf("Symfony\Component\HttpFoundation\Response", $response);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
|
||||
$this->assertEquals('inline; filename="cestlafete.jpg"', $response->headers->get('content-disposition'));
|
||||
$this->assertEquals(0, $response->getMaxAge());
|
||||
$response->setPrivate();
|
||||
@@ -45,7 +45,7 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCase
|
||||
|
||||
$response = $this->factory->deliverFile(__DIR__ . '/../../../../files/cestlafete.jpg', 'toto.jpg');
|
||||
|
||||
$this->assertInstanceOf("Symfony\Component\HttpFoundation\Response", $response);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
|
||||
$this->assertEquals('inline; filename="toto.jpg"', $response->headers->get('content-disposition'));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCase
|
||||
|
||||
$response = $this->factory->deliverFile(__DIR__ . '/../../../../files/cestlafete.jpg', 'toto.jpg', 'attachment');
|
||||
|
||||
$this->assertInstanceOf("Symfony\Component\HttpFoundation\Response", $response);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
|
||||
$this->assertEquals('attachment; filename="toto.jpg"', $response->headers->get('content-disposition'));
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCase
|
||||
$response = $this->factory->deliverFile(__DIR__ . '/../../../../files/cestlafete.jpg', 'toto.jpg', 'attachment');
|
||||
$response->prepare($request);
|
||||
|
||||
$this->assertInstanceOf("Symfony\Component\HttpFoundation\Response", $response);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
|
||||
$this->assertEquals('attachment; filename="toto.jpg"', $response->headers->get('content-disposition'));
|
||||
$this->assertEquals('/protected/cestlafete.jpg', $response->headers->get('x-accel-redirect'));
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCase
|
||||
$response = $this->factory->deliverFile(__DIR__ . '/../../../../files/cestlafete.jpg', 'toto.jpg', 'attachment');
|
||||
$response->prepare($request);
|
||||
|
||||
$this->assertInstanceOf("Symfony\Component\HttpFoundation\Response", $response);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
|
||||
$this->assertEquals('attachment; filename="toto.jpg"', $response->headers->get('content-disposition'));
|
||||
$this->assertEquals('/protected/cestlafete.jpg', $response->headers->get('x-accel-redirect'));
|
||||
}
|
||||
@@ -136,7 +136,7 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCase
|
||||
$response = $this->factory->deliverFile($file, 'PhraseanetTestCase.php', 'attachment');
|
||||
$response->prepare($request);
|
||||
|
||||
$this->assertInstanceOf("Symfony\Component\HttpFoundation\Response", $response);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
|
||||
$this->assertEquals('attachment; filename="PhraseanetTestCase.php"', $response->headers->get('content-disposition'));
|
||||
$this->assertEquals(realpath($file), $response->headers->get('x-accel-redirect'));
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCase
|
||||
|
||||
$response = $this->factory->deliverData($data, 'data.csv', 'text/csv', 'attachment');
|
||||
|
||||
$this->assertInstanceOf("Symfony\Component\HttpFoundation\Response", $response);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
|
||||
$this->assertEquals('attachment; filename="data.csv"', $response->headers->get('content-disposition'));
|
||||
$this->assertEquals('text/csv', $response->headers->get('content-type'));
|
||||
$this->assertEquals($data, $response->getContent());
|
||||
|
@@ -5,7 +5,7 @@ namespace Alchemy\Tests\Phrasea\Http\XSendFile;
|
||||
use Alchemy\Phrasea\Http\XSendFile\NginxMode;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class NginxModeTest extends \PhraseanetTestCase
|
||||
class NginxModeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetVirtualHost()
|
||||
{
|
||||
@@ -43,7 +43,7 @@ class NginxModeTest extends \PhraseanetTestCase
|
||||
$mode->setHeaders($request);
|
||||
$this->assertArrayHasKey('x-sendfile-type', $request->headers->all());
|
||||
$this->assertArrayHasKey('x-accel-mapping', $request->headers->all());
|
||||
$this->assertEquals('/protected='.realpath($protected).',/uploads='.realpath($upload), $request->headers->get('X-Accel-Mapping'));
|
||||
$this->assertEquals(realpath($protected).'=/protected,'.realpath($upload).'=/uploads', $request->headers->get('X-Accel-Mapping'));
|
||||
}
|
||||
|
||||
public function testSetInvalidHeaders()
|
||||
|
Reference in New Issue
Block a user