add PHP errors options to XML schema definition

This commit is contained in:
Christian Flothmann 2018-04-02 10:22:38 +02:00
parent b3fc3b5690
commit ad8c8d00aa
8 changed files with 68 additions and 0 deletions

View File

@ -29,6 +29,7 @@
<xsd:element name="property-info" type="property_info" minOccurs="0" maxOccurs="1" />
<xsd:element name="cache" type="cache" minOccurs="0" maxOccurs="1" />
<xsd:element name="workflow" type="workflow" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="php-errors" type="php-errors" minOccurs="0" maxOccurs="1" />
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
<xsd:element name="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
</xsd:choice>
@ -285,6 +286,11 @@
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>
<xsd:complexType name="php-errors">
<xsd:attribute name="log" type="xsd:boolean" />
<xsd:attribute name="throw" type="xsd:boolean" />
</xsd:complexType>
<xsd:complexType name="marking_store">
<xsd:sequence>
<xsd:element name="argument" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />

View File

@ -0,0 +1,8 @@
<?php
$container->loadFromExtension('framework', array(
'php_errors' => array(
'log' => false,
'throw' => false,
),
));

View File

@ -0,0 +1,8 @@
<?php
$container->loadFromExtension('framework', array(
'php_errors' => array(
'log' => true,
'throw' => true,
),
));

View File

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:php-errors log="false" throw="false" />
</framework:config>
</container>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:php-errors log="true" throw="true" />
</framework:config>
</container>

View File

@ -0,0 +1,3 @@
framework:
php_errors:
throw: false

View File

@ -0,0 +1,4 @@
framework:
php_errors:
log: true
throw: true

View File

@ -28,6 +28,7 @@ use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@ -335,6 +336,22 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertTrue($container->hasDefinition('console.command.workflow_dump'));
}
public function testEnabledPhpErrorsConfig()
{
$container = $this->createContainerFromFile('php_errors_enabled');
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $container->getDefinition('debug.debug_handlers_listener')->getArgument(1));
$this->assertSame(-1, $container->getParameter('debug.error_handler.throw_at'));
}
public function testDisabledPhpErrorsConfig()
{
$container = $this->createContainerFromFile('php_errors_disabled');
$this->assertNull($container->getDefinition('debug.debug_handlers_listener')->getArgument(1));
$this->assertSame(0, $container->getParameter('debug.error_handler.throw_at'));
}
public function testRouter()
{
$container = $this->createContainerFromFile('full');