Skip to content

Commit d005f12

Browse files
committed
RequestPropsExtractorTest
1 parent d650287 commit d005f12

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/LiveComponent/src/Util/RequestPropsExtractor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function extract(Request $request, LiveComponentMetadata $metadata, objec
3535
{
3636
$parameters = array_merge($request->attributes->all(), $request->query->all());
3737

38-
// @todo never empty because custom values prefixed with _ ... do something ?
3938
if (empty($parameters)) {
4039
return [];
4140
}

src/LiveComponent/tests/Functional/Util/RequestPropsExtractorTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ class RequestPropsExtractorTest extends KernelTestCase
2525
/**
2626
* @dataProvider getQueryStringTests
2727
*/
28-
public function testExtract(string $queryString, array $expected)
28+
public function testExtractFromQueryString(string $queryString, array $expected, array $attributes = []): void
2929
{
3030
$extractor = new RequestPropsExtractor($this->hydrator());
3131

3232
$request = Request::create('/'.!empty($queryString) ? '?'.$queryString : '');
33+
$request->attributes->add($attributes);
3334

3435
/** @var LiveComponentMetadataFactory $metadataFactory */
3536
$metadataFactory = self::getContainer()->get('ux.live_component.metadata_factory');
@@ -65,6 +66,10 @@ public function getQueryStringTests(): iterable
6566
'invalid array value' => ['arrayProp=foo', []],
6667
'invalid object value' => ['objectProp=foo', []],
6768
'aliased prop' => ['q=foo', ['boundPropWithAlias' => 'foo']],
69+
'attribute prop' => ['', ['stringProp' => 'foo'], ['stringProp' => 'foo']],
70+
'attribute aliased prop' => ['', ['boundPropWithAlias' => 'foo'], ['q' => 'foo']],
71+
'attribute not bound prop' => ['', [], ['unboundProp' => 'foo']],
72+
'query priority' => ['stringProp=foo', ['stringProp' => 'foo'], ['stringProp' => 'bar']],
6873
];
6974
}
7075
}

0 commit comments

Comments
 (0)