Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix 2.2 support

  • Loading branch information...
commit aabbbf36262d743c73fed822866842b32aff2d88 1 parent c4a5aad
@rande rande authored
View
5 Form/Type/ServiceListType.php
@@ -13,6 +13,7 @@
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\AbstractType;
+use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
@@ -64,6 +65,10 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'expanded' => false,
'choices' => function (Options $options, $previousValue) use ($contexts, $manager) {
if (!isset($contexts[$options['context']])) {
+ if (Kernel::MINOR_VERSION < 3) {
+ throw new \RuntimeException(sprintf('Invalid context: `%s`', $options['context']));
+ }
+
throw new InvalidArgumentException(sprintf('Invalid context: `%s`', $options['context']));
}
View
11 Tests/Form/Type/ServiceListTypeTest.php
@@ -11,6 +11,7 @@
namespace Sonata\BlockBundle\Tests\Form\Type;
use Sonata\BlockBundle\Form\Type\ServiceListType;
+use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ServiceListTypeTest extends \PHPUnit_Framework_TestCase
@@ -26,12 +27,14 @@ public function testFormType()
$this->assertEquals('choice', $type->getParent());
}
- /**
- *
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- */
public function testOptionsWithInvalidContext()
{
+ if (Kernel::MINOR_VERSION < 3) {
+ $this->setExpectedException('RuntimeException');
+ } else {
+ $this->setExpectedException('\Symfony\Component\Form\Exception\InvalidArgumentException');
+ }
+
$blockServiceManager = $this->getMock('Sonata\BlockBundle\Block\BlockServiceManagerInterface');
$type = new ServiceListType($blockServiceManager);
View
2  composer.json
@@ -17,7 +17,7 @@
}
],
"require": {
- "symfony/http-foundation": "~2.2",
+ "symfony/http-kernel": "~2.2",
"symfony/form": "~2.2",
"doctrine/common": "~2.3",
"knplabs/knp-menu-bundle": "~1.1",
Please sign in to comment.
Something went wrong with that request. Please try again.