Skip to content

Commit 475c928

Browse files
committed
Inline constant value
1 parent 503f12a commit 475c928

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tests/Serializer/Handler/PagerfantaHandlerTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use PHPUnit\Framework\Attributes\DataProvider;
1515
use PHPUnit\Framework\TestCase;
1616

17+
/**
18+
* @note The {@see PagerfantaHandler::PRESERVE_KEYS_KEY} constant value is inlined to avoid autoloader issues when the JMS packages are not installed
19+
*/
1720
final class PagerfantaHandlerTest extends TestCase
1821
{
1922
public static function setUpBeforeClass(): void
@@ -41,9 +44,9 @@ public static function dataSerializeWithPreserveKeysContext(): \Generator
4144
{
4245
yield 'Context not set' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], [], '{"items":{"0":"item1","2":"item2","4":"item3"},"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
4346

44-
yield 'Context with preserve keys disabled' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], [PagerfantaHandler::PRESERVE_KEYS_KEY => false], '{"items":["item1","item2","item3"],"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
47+
yield 'Context with preserve keys disabled' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], ['pagerfanta_preserve_keys' => false], '{"items":["item1","item2","item3"],"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
4548

46-
yield 'Context with preserve keys enabled' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], [PagerfantaHandler::PRESERVE_KEYS_KEY => true], '{"items":{"0":"item1","2":"item2","4":"item3"},"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
49+
yield 'Context with preserve keys enabled' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], ['pagerfanta_preserve_keys' => true], '{"items":{"0":"item1","2":"item2","4":"item3"},"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
4750
}
4851

4952
/**
@@ -75,7 +78,7 @@ public function testNormalizeRejectsInvalidPreserveKeysContext(): void
7578
$pager->setMaxPerPage(5);
7679

7780
$serializationContext = new SerializationContext();
78-
$serializationContext->setAttribute(PagerfantaHandler::PRESERVE_KEYS_KEY, 'invalid');
81+
$serializationContext->setAttribute('pagerfanta_preserve_keys', 'invalid');
7982

8083
$this->createSerializer()->serialize($pager, 'json', $serializationContext);
8184
}

0 commit comments

Comments
 (0)