Skip to content

Commit

Permalink
Fix bug that triggers error when using both deprecated and new option…
Browse files Browse the repository at this point in the history
… keys
  • Loading branch information
Jean85 committed Aug 8, 2017
1 parent 70ecbbf commit 938770b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ private function checkConfigurationOnForInvalidSettings(array $config, Container
}

// both are used
if ($config[$option] !== $default && $config['options'][$option] !== $default) {
if (
$config[$option] !== $default
&& $config['options'][$option] !== $default
&& $config['options'][$option] !== $config[$option]
) {
$message = sprintf(
'You are using both the deprecated option sentry.%s and the new sentry.options.%s, but values do not match. Drop the deprecated one or make the values identical.',
$option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Sentry\SentryBundle\DependencyInjection\SentryExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class ExtensionTest extends \PHPUnit_Framework_TestCase
class SentryExtensionTest extends \PHPUnit_Framework_TestCase
{
const CONFIG_ROOT = 'sentry';

Expand Down Expand Up @@ -52,6 +52,38 @@ public function test_that_it_uses_app_path_value()
);
}

public function test_that_it_uses_both_new_and_deprecated_values()
{
$container = $this->getContainer(
array(
static::CONFIG_ROOT => array(
'app_path' => 'sentry/app/path',
'options' => array('app_path' => 'sentry/app/path'),
),
)
);

$options = $container->getParameter('sentry.options');
$this->assertSame(
'sentry/app/path',
$options['app_path']
);
}

public function test_that_throws_exception_if_new_and_deprecated_values_dont_match()
{
$this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');

$this->getContainer(
array(
'app_path' => 'sentry/app/path',
static::CONFIG_ROOT => array(
'options' => array('app_path' => 'sentry/different/app/path'),
),
)
);
}

public function test_vendor_in_deprecated_default_excluded_paths()
{
$container = $this->getContainer();
Expand Down

0 comments on commit 938770b

Please sign in to comment.