feat: add Liquid filter 'group_by'
Some checks are pending
tests / ci (push) Waiting to run

This commit is contained in:
Benjamin Nussbaum 2025-08-25 14:43:22 +02:00
parent f4f8ab5181
commit 25f36eaf54
3 changed files with 152 additions and 0 deletions

View file

@ -228,4 +228,28 @@ LIQUID
// Should return the fallback value
$this->assertStringContainsString('Not Found', $result);
}
public function test_plugin_with_group_by_filter(): void
{
$plugin = Plugin::factory()->create([
'markup_language' => 'liquid',
'render_markup' => <<<'LIQUID'
{{ collection | group_by: 'age' | json }}
LIQUID
,
'data_payload' => [
'collection' => [
['name' => 'Ryan', 'age' => 35],
['name' => 'Sara', 'age' => 29],
['name' => 'Jimbob', 'age' => 29],
],
],
]);
$result = $plugin->render('full');
// Should output JSON representation of grouped data
$this->assertStringContainsString('"35":[{"name":"Ryan","age":35}]', $result);
$this->assertStringContainsString('"29":[{"name":"Sara","age":29},{"name":"Jimbob","age":29}]', $result);
}
}