Skip to content

Commit cdc6095

Browse files
xabbuhGuilhemN
authored andcommitted
the Regex constraint is resolvable (#1591)
* the Regex constraint is resolvable * Add a test case * Update ParamFetcherController.php
1 parent aef3e03 commit cdc6095

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

Tests/Functional/Bundle/TestBundle/Controller/ParamFetcherController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
class ParamFetcherController extends FOSRestController
2424
{
2525
/**
26-
* @RequestParam(name="raw", requirements=@IdenticalTo({"foo"="raw", "bar"="foo"}), default="invalid")
27-
* @RequestParam(name="map", map=true, requirements=@IdenticalTo({"foo"="map", "foobar"="foo"}), default="%invalid2% %%")
28-
* @RequestParam(name="bar", map=true, requirements="%bar% foo", strict=true)
26+
* @RequestParam(name="raw", requirements=@IdenticalTo({"foo"="raw", "bar"="foo"}), default="invalid", strict=false)
27+
* @RequestParam(name="map", map=true, requirements=@IdenticalTo({"foo"="map", "foobar"="foo"}), default="%invalid2% %%", strict=false)
28+
* @RequestParam(name="bar", nullable=true, requirements="%bar%\ foo")
2929
*/
3030
public function paramsAction(ParamFetcherInterface $fetcher)
3131
{
32-
return new JsonResponse($fetcher->all(false));
32+
return new JsonResponse($fetcher->all());
3333
}
3434

3535
/**

Tests/Functional/ParamFetcherTest.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,9 @@ public function testValidMapParameter()
5050
'foo' => $this->validMap,
5151
'bar' => $this->validMap,
5252
];
53-
$this->client->request('POST', '/params', ['raw' => 'bar', 'map' => $map]);
53+
$this->client->request('POST', '/params', ['raw' => 'bar', 'map' => $map, 'bar' => 'bar foo']);
5454

55-
$this->assertEquals(['raw' => 'invalid', 'map' => $map, 'bar' => null], $this->getData());
56-
}
57-
58-
public function testFooParameter()
59-
{
60-
$value = ['bar foo', 'bar foo'];
61-
$this->client->request('POST', '/params', ['foo' => $value]);
62-
63-
$map = array(
64-
'foo' => $this->validMap,
65-
'bar' => $this->validMap,
66-
);
67-
$this->client->request('POST', '/params', array('raw' => 'bar', 'map' => $map));
68-
69-
$this->assertEquals(array('raw' => 'invalid', 'map' => $map, 'bar' => null), $this->getData());
55+
$this->assertEquals(['raw' => 'invalid', 'map' => $map, 'bar' => 'bar foo'], $this->getData());
7056
}
7157

7258
public function testWithSubRequests()

Validator/Constraints/Regex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Ener-Getick <[email protected]>
2222
*/
23-
class Regex extends BaseRegex
23+
class Regex extends BaseRegex implements ResolvableConstraintInterface
2424
{
2525
use ResolverTrait;
2626

0 commit comments

Comments
 (0)