Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '2.8'

* 2.8: (65 commits)
  [VarDumper] Fix tests for HHVM
  Update DateTimeToArrayTransformer.php
  Mock microtime() and time() in transient tests
  Azerbaijani language pluralization rule
  Move HHVM tests out of the allowed failures
  Fix merge
  [2.6] Towards 100% HHVM compat
  [Security/Http] Fix test
  [Stopwatch] Fix test
  Minor fixes
  [Validator] Added missing error codes and turned codes into UUIDs
  Towards 100% HHVM compat
  Warmup twig templates in non-standard paths (closes #12507)
  [Bridge/PhpUnit] Enforce a consistent locale
  Fix param order of assertEquals (expected, actual) in test for Finder\Glob
  Fix choice translation domain for expanded choice widget
  unify default AccessDeniedExeption message
  trigger event with right user (add test)
  [Security] Initialize SwitchUserEvent::targetUser on attemptExitUser
  fixed CS
  ...

Conflicts:
	UPGRADE-2.8.md
	src/Symfony/Bridge/ProxyManager/composer.json
	src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php
	src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php
	src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
	src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
	src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
	src/Symfony/Bundle/FrameworkBundle/Resources/config/old_assets.xml
	src/Symfony/Bundle/FrameworkBundle/Resources/config/test.xml
	src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.md
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.md
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.json
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.md
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.txt
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_1.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.json
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.md
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.txt
	src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/legacy_synchronized_service_definition_2.xml
	src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php
	src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml
	src/Symfony/Bundle/SecurityBundle/composer.json
	src/Symfony/Component/Debug/ErrorHandler.php
	src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php
	src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
	src/Symfony/Component/DependencyInjection/Definition.php
	src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
	src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
	src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
	src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
	src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/legacy-container9.php
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/legacy-services9.dot
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services6.xml
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services9.xml
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services6.yml
	src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services9.yml
	src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
	src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
	src/Symfony/Component/Form/ResolvedFormType.php
	src/Symfony/Component/Form/Tests/CompoundFormTest.php
	src/Symfony/Component/Process/Tests/AbstractProcessTest.php
	src/Symfony/Component/VarDumper/Tests/CliDumperTest.php
	src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
  • Loading branch information...
commit 062422a490fac7ba355a509dd199365e6d8adaa6 2 parents 42a69a8 + f93ebc2
@nicolas-grekas nicolas-grekas authored
Showing with 53 additions and 12 deletions.
  1. +2 −2 Processor/WebProcessor.php
  2. +51 −10 Tests/Processor/WebProcessorTest.php
View
4 Processor/WebProcessor.php
@@ -21,10 +21,10 @@
*/
class WebProcessor extends BaseWebProcessor
{
- public function __construct()
+ public function __construct(array $extraFields = null)
{
// Pass an empty array as the default null value would access $_SERVER
- parent::__construct(array());
+ parent::__construct(array(), $extraFields);
}
public function onKernelRequest(GetResponseEvent $event)
View
61 Tests/Processor/WebProcessorTest.php
@@ -19,6 +19,42 @@ class WebProcessorTest extends \PHPUnit_Framework_TestCase
{
public function testUsesRequestServerData()
{
+ list($event, $server) = $this->createRequestEvent();
+
+ $processor = new WebProcessor();
+ $processor->onKernelRequest($event);
+ $record = $processor($this->getRecord());
+
+ $this->assertCount(5, $record['extra']);
+ $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']);
+ $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']);
+ $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']);
+ $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
+ $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
+ }
+
+ public function testCanBeConstructedWithExtraFields()
+ {
+ if (!$this->isExtraFieldsSupported()) {
+ $this->markTestSkipped('WebProcessor of the installed Monolog version does not support $extraFields parameter');
+ }
+
+ list($event, $server) = $this->createRequestEvent();
+
+ $processor = new WebProcessor(array('url', 'referrer'));
+ $processor->onKernelRequest($event);
+ $record = $processor($this->getRecord());
+
+ $this->assertCount(2, $record['extra']);
+ $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']);
+ $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
+ }
+
+ /**
+ * @return array
+ */
+ private function createRequestEvent()
+ {
$server = array(
'REQUEST_URI' => 'A',
'REMOTE_ADDR' => 'B',
@@ -40,15 +76,7 @@ public function testUsesRequestServerData()
->method('getRequest')
->will($this->returnValue($request));
- $processor = new WebProcessor();
- $processor->onKernelRequest($event);
- $record = $processor($this->getRecord());
-
- $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']);
- $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']);
- $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']);
- $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
- $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
+ return array($event, $server);
}
/**
@@ -57,7 +85,7 @@ public function testUsesRequestServerData()
*
* @return array Record
*/
- protected function getRecord($level = Logger::WARNING, $message = 'test')
+ private function getRecord($level = Logger::WARNING, $message = 'test')
{
return array(
'message' => $message,
@@ -69,4 +97,17 @@ protected function getRecord($level = Logger::WARNING, $message = 'test')
'extra' => array(),
);
}
+
+ private function isExtraFieldsSupported()
+ {
+ $monologWebProcessorClass = new \ReflectionClass('Monolog\Processor\WebProcessor');
+
+ foreach ($monologWebProcessorClass->getConstructor()->getParameters() as $parameter) {
+ if ('extraFields' === $parameter->getName()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.