Skip to content

Commit c8a5052

Browse files
committed
Merge pull request #300 from symfony-cmf/remove_deprecations
Remove deprecations
2 parents d1fdc64 + ca07d99 commit c8a5052

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

Form/Type/RouteTypeType.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@
1212
namespace Symfony\Cmf\Bundle\RoutingBundle\Form\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15+
use Symfony\Component\OptionsResolver\OptionsResolver;
1516
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
1617

1718
class RouteTypeType extends AbstractType
1819
{
1920
protected $routeTypes = array();
2021
protected $translator;
2122

22-
public function setDefaultOptions(OptionsResolverInterface $resolver)
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function configureOptions(OptionsResolver $resolver)
2327
{
2428
$choices = array();
2529
foreach ($this->routeTypes as $routeType) {
@@ -32,6 +36,16 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
3236
));
3337
}
3438

39+
/**
40+
* {@inheritdoc}
41+
*
42+
* @todo Remove when Symfony <2.7 support is dropped.
43+
*/
44+
public function setDefaultOptions(OptionsResolverInterface $resolver)
45+
{
46+
$this->configureOptions($resolver);
47+
}
48+
3549
/**
3650
* Register a route type
3751
*

Tests/Functional/Doctrine/Phpcr/RouteTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public function testPersist()
4040

4141
$this->getDm()->persist($route);
4242
$this->getDm()->flush();
43-
$this->assertEquals('/testroute', $route->getPattern());
43+
$this->assertEquals('/testroute', $route->getPath());
4444

4545
$this->getDm()->clear();
4646

4747
$route = $this->getDm()->find(null, self::ROUTE_ROOT.'/testroute');
4848

4949
$this->assertNotNull($route->getContent());
50-
$this->assertEquals('/testroute', $route->getPattern());
50+
$this->assertEquals('/testroute', $route->getPath());
5151

5252
$this->assertEquals('y', $route->getDefault('x'));
5353
$defaults = $route->getDefaults();
@@ -93,13 +93,13 @@ public function testPersistEmptyOptions()
9393
public function testRootRoute()
9494
{
9595
$root = $this->getDm()->find(null, self::ROUTE_ROOT);
96-
$this->assertEquals('/', $root->getPattern());
96+
$this->assertEquals('/', $root->getPath());
9797
}
9898

9999
public function testSetPattern()
100100
{
101101
$root = $this->getDm()->find(null, self::ROUTE_ROOT);
102-
$root->setPattern('/{test}');
102+
$root->setPath('/{test}');
103103
$this->assertEquals('{test}', $root->getVariablePattern());
104104
}
105105

@@ -110,7 +110,7 @@ public function testSetPattern()
110110
*/
111111
public function testSetPatternInvalid(Route $route)
112112
{
113-
$route->setPattern('/impossible');
113+
$route->setPath('/impossible');
114114
}
115115

116116
/**
@@ -120,7 +120,7 @@ public function testInvalidIdPrefix()
120120
{
121121
$root = $this->getDm()->find(null, self::ROUTE_ROOT);
122122
$root->setPrefix('/changed'); // simulate a problem with the prefix setter listener
123-
$this->assertEquals('/', $root->getPattern());
123+
$this->assertEquals('/', $root->getPath());
124124
}
125125

126126
/**
@@ -129,7 +129,7 @@ public function testInvalidIdPrefix()
129129
public function testPrefixNonpersisted()
130130
{
131131
$route = new Route();
132-
$route->getPattern();
132+
$route->getPath();
133133
}
134134

135135
public function testDefaultFormat()
@@ -146,6 +146,6 @@ public function testDefaultFormat()
146146

147147
$route = $this->getDm()->find(null, self::ROUTE_ROOT.'/format');
148148

149-
$this->assertEquals('/format.{_format}', $route->getPattern());
149+
$this->assertEquals('/format.{_format}', $route->getPath());
150150
}
151151
}

Tests/Functional/Routing/DynamicRouterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testNotAllowed()
141141
// do not set a content here, or we need a valid request and so on...
142142
$route = new Route();
143143
$route->setPosition($root, 'notallowed');
144-
$route->setRequirement('_method', 'GET');
144+
$route->setMethods(array('GET'));
145145
$route->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController');
146146
$this->getDm()->persist($route);
147147
$this->getDm()->flush();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
symfony_route:
2-
pattern: /symfony_route_test
2+
path: /symfony_route_test
33
defaults: { _controller: Test:controller }

Tests/Unit/Form/Type/RouteTypeTypeTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ class RouteTypeTypeTest extends \PHPUnit_Framework_Testcase
1919
public function setUp()
2020
{
2121
$this->type = new RouteTypeType;
22-
$this->ori = $this->getMock(
23-
'Symfony\Component\OptionsResolver\OptionsResolverInterface');
2422
}
2523

2624
public function testSetDefaultOptions()
2725
{
2826
$type = new RouteTypeType;
2927
$optionsResolver = new OptionsResolver();
3028

31-
$type->setDefaultOptions($optionsResolver);
29+
$type->configureOptions($optionsResolver);
3230

3331
$options = $optionsResolver->resolve();
3432

@@ -40,7 +38,8 @@ public function testDefaultsSet()
4038
$this->type->addRouteType('foobar');
4139
$this->type->addRouteType('barfoo');
4240

43-
$this->ori->expects($this->once())
41+
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver');
42+
$optionsResolver->expects($this->once())
4443
->method('setDefaults')
4544
->with(array(
4645
'choices' => array(
@@ -50,6 +49,6 @@ public function testDefaultsSet()
5049
'translation_domain' => 'CmfRoutingBundle',
5150
));
5251

53-
$this->type->setDefaultOptions($this->ori);
52+
$this->type->configureOptions($optionsResolver);
5453
}
5554
}

0 commit comments

Comments
 (0)