public function testItAddsRequestTrustedProxiesSubscriberOnBoot()
{
$app = new Application();
$app['root.path'] = __DIR__ . '/../../../../../..';
$app->register(new ConfigurationServiceProvider());
$app['phraseanet.configuration.config-path'] = __DIR__ . '/fixtures/config-proxies.yml';
$app['phraseanet.configuration.config-compiled-path'] = __DIR__ . '/fixtures/config-proxies.php';
$app->boot();
/** @var EventDispatcherInterface $dispatcher */
$dispatcher = $app['dispatcher'];
$listener = null;
$method = null;
foreach ($dispatcher->getListeners(KernelEvents::REQUEST) as $callable) {
// Only look for TrustedProxySubscriber instances
if (!is_array($callable)) {
continue;
}
list($listener, $method) = $callable;
if ($listener instanceof TrustedProxySubscriber) {
break;
}
}
$this->assertInstanceOf('Alchemy\\Phrasea\\Core\\Event\\Subscriber\\TrustedProxySubscriber', $listener, 'TrustedProxySubscriber was not properly registered');
$this->assertEquals('setProxyConf', $method);
$this->assertSame([], Request::getTrustedProxies());
$listener->setProxyConf();
$this->assertSame(['127.0.0.1', '66.6.66.6'], Request::getTrustedProxies());
unlink($app['phraseanet.configuration.config-compiled-path']);
}