Autoformat lol

This commit is contained in:
James Cole
2026-01-23 15:09:50 +01:00
parent ae1347c550
commit 8f15a32bd6
1071 changed files with 21111 additions and 21687 deletions

View File

@@ -1,6 +1,5 @@
<?php
/*
* AbstractQueryParserInterfaceParseQueryTester.php
* Copyright (c) 2025 james@firefly-iii.org
@@ -26,10 +25,10 @@ declare(strict_types=1);
namespace Tests\unit\Support\Search\QueryParser;
use FireflyIII\Support\Search\QueryParser\FieldNode;
use FireflyIII\Support\Search\QueryParser\Node;
use FireflyIII\Support\Search\QueryParser\NodeGroup;
use FireflyIII\Support\Search\QueryParser\QueryParserInterface;
use FireflyIII\Support\Search\QueryParser\StringNode;
use FireflyIII\Support\Search\QueryParser\NodeGroup;
use FireflyIII\Support\Search\QueryParser\Node;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\integration\TestCase;
@@ -47,143 +46,72 @@ abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase
$actual = $this->createParser()->parse($query);
$this->assertObjectEquals($expected, $actual);
}
public static function queryDataProvider(): iterable
{
yield 'empty query' => [
'',
new NodeGroup([]),
];
yield 'empty query' => ['', new NodeGroup([])];
yield 'simple word' => [
'groceries',
new NodeGroup([new StringNode('groceries')]),
];
yield 'simple word' => ['groceries', new NodeGroup([new StringNode('groceries')])];
yield 'prohibited word' => [
'-groceries',
new NodeGroup([new StringNode('groceries', true)]),
];
yield 'prohibited word' => ['-groceries', new NodeGroup([new StringNode('groceries', true)])];
yield 'prohibited field' => [
'-amount:100',
new NodeGroup([new FieldNode('amount', '100', true)]),
];
yield 'prohibited field' => ['-amount:100', new NodeGroup([new FieldNode('amount', '100', true)])];
yield 'quoted word' => [
'"test phrase"',
new NodeGroup([new StringNode('test phrase')]),
];
yield 'quoted word' => ['"test phrase"', new NodeGroup([new StringNode('test phrase')])];
yield 'prohibited quoted word' => [
'-"test phrase"',
new NodeGroup([new StringNode('test phrase', true)]),
];
yield 'prohibited quoted word' => ['-"test phrase"', new NodeGroup([new StringNode('test phrase', true)])];
yield 'multiple words' => [
'groceries shopping market',
new NodeGroup([
new StringNode('groceries'),
new StringNode('shopping'),
new StringNode('market'),
]),
new NodeGroup([new StringNode('groceries'), new StringNode('shopping'), new StringNode('market')])
];
yield 'field operator' => [
'amount:100',
new NodeGroup([new FieldNode('amount', '100')]),
];
yield 'field operator' => ['amount:100', new NodeGroup([new FieldNode('amount', '100')])];
yield 'quoted field value with single space' => [
'description:"test phrase"',
new NodeGroup([new FieldNode('description', 'test phrase')]),
];
yield 'quoted field value with single space' => ['description:"test phrase"', new NodeGroup([new FieldNode('description', 'test phrase')])];
yield 'multiple fields' => [
'amount:100 category:food',
new NodeGroup([
new FieldNode('amount', '100'),
new FieldNode('category', 'food'),
]),
];
yield 'multiple fields' => ['amount:100 category:food', new NodeGroup([new FieldNode('amount', '100'), new FieldNode('category', 'food')])];
yield 'simple subquery' => [
'(amount:100 category:food)',
new NodeGroup([
new NodeGroup([
new FieldNode('amount', '100'),
new FieldNode('category', 'food'),
]),
]),
new NodeGroup([new NodeGroup([new FieldNode('amount', '100'), new FieldNode('category', 'food')])])
];
yield 'prohibited subquery' => [
'-(amount:100 category:food)',
new NodeGroup([
new NodeGroup([
new FieldNode('amount', '100'),
new FieldNode('category', 'food'),
], true),
]),
new NodeGroup([new NodeGroup([new FieldNode('amount', '100'), new FieldNode('category', 'food')], true)])
];
yield 'nested subquery' => [
'(amount:100 (description:"test" category:food))',
new NodeGroup([
new NodeGroup([
new FieldNode('amount', '100'),
new NodeGroup([
new FieldNode('description', 'test'),
new FieldNode('category', 'food'),
]),
]),
]),
new NodeGroup([new NodeGroup([
new FieldNode('amount', '100'),
new NodeGroup([new FieldNode('description', 'test'), new FieldNode('category', 'food')])
])])
];
yield 'mixed words and operators' => [
'groceries amount:50 shopping',
new NodeGroup([
new StringNode('groceries'),
new FieldNode('amount', '50'),
new StringNode('shopping'),
]),
new NodeGroup([new StringNode('groceries'), new FieldNode('amount', '50'), new StringNode('shopping')])
];
yield 'subquery after field value' => [
'amount:100 (description:"market" category:food)',
new NodeGroup([
new FieldNode('amount', '100'),
new NodeGroup([
new FieldNode('description', 'market'),
new FieldNode('category', 'food'),
]),
]),
new NodeGroup([new FieldNode('amount', '100'), new NodeGroup([new FieldNode('description', 'market'), new FieldNode('category', 'food')])])
];
yield 'word followed by subquery' => [
'groceries (amount:100 description_contains:"test")',
new NodeGroup([
new StringNode('groceries'),
new NodeGroup([
new FieldNode('amount', '100'),
new FieldNode('description_contains', 'test'),
]),
]),
new NodeGroup([new StringNode('groceries'), new NodeGroup([new FieldNode('amount', '100'), new FieldNode('description_contains', 'test')])])
];
yield 'nested subquery with prohibited field' => [
'(amount:100 (description_contains:"test payment" -has_attachments:true))',
new NodeGroup([
new NodeGroup([
new FieldNode('amount', '100'),
new NodeGroup([
new FieldNode('description_contains', 'test payment'),
new FieldNode('has_attachments', 'true', true),
]),
]),
]),
new NodeGroup([new NodeGroup([
new FieldNode('amount', '100'),
new NodeGroup([new FieldNode('description_contains', 'test payment'), new FieldNode('has_attachments', 'true', true)])
])])
];
yield 'complex nested subqueries' => [
@@ -197,43 +125,26 @@ abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase
new FieldNode('category', 'food', true),
new StringNode('word'),
new FieldNode('description', 'test phrase'),
new NodeGroup([
new FieldNode('has_notes', 'true'),
]),
]),
]),
]),
new NodeGroup([new FieldNode('has_notes', 'true')])
])
])
])
];
yield 'word with multiple spaces' => [
'"multiple spaces"',
new NodeGroup([new StringNode('multiple spaces')]),
];
yield 'word with multiple spaces' => ['"multiple spaces"', new NodeGroup([new StringNode('multiple spaces')])];
yield 'field with multiple spaces in value' => [
'description:"multiple spaces here"',
new NodeGroup([new FieldNode('description', 'multiple spaces here')]),
new NodeGroup([new FieldNode('description', 'multiple spaces here')])
];
yield 'unmatched right parenthesis in word' => [
'test)word',
new NodeGroup([new StringNode('test)word')]),
];
yield 'unmatched right parenthesis in word' => ['test)word', new NodeGroup([new StringNode('test)word')])];
yield 'unmatched right parenthesis in field' => [
'description:test)phrase',
new NodeGroup([new FieldNode('description', 'test)phrase')]),
];
yield 'unmatched right parenthesis in field' => ['description:test)phrase', new NodeGroup([new FieldNode('description', 'test)phrase')])];
yield 'subquery followed by word' => [
'(amount:100 category:food) shopping',
new NodeGroup([
new NodeGroup([
new FieldNode('amount', '100'),
new FieldNode('category', 'food'),
]),
new StringNode('shopping'),
]),
new NodeGroup([new NodeGroup([new FieldNode('amount', '100'), new FieldNode('category', 'food')]), new StringNode('shopping')])
];
}
}