FilterParserTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 10
c 2
b 1
f 1
dl 0
loc 15
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testParse() 0 12 1
1
<?php declare(strict_types = 1);
2
3
namespace Apicart\FQL\Tests\Generator\SQL;
4
5
use Apicart\FQL\Tests\Integration\FilterParser;
6
use Apicart\FQL\Tests\Integration\Generator\SQL\Resolver\ItemFilterResolver;
7
use PHPUnit\Framework\TestCase;
8
9
final class FilterParserTest extends TestCase
10
{
11
12
    public function testParse(): void
13
    {
14
        $fql = 'q:"samsung" AND introducedAt:["2019-01-01 00:00:00" TO "2019-01-31 23:59:59"]'
15
            . ' AND NOT type:(tv OR "mobile phone") OR (price:{"10" TO *] OR price:{"30" TO *])';
16
        $resolver = new ItemFilterResolver;
17
18
        $sql = FilterParser::parse($fql, $resolver);
19
        self::assertSame(
20
            "name ILIKE '%samsung%'"
21
            . " AND (introduced_at >= '2019-01-01T00:00:00+00:00' AND introduced_at <= '2019-01-31T23:59:59+00:00')"
22
            . " AND NOT ((type = 'tv' OR type = 'mobile phone')) OR ((price > 10) OR (price > 30))",
23
            $sql
24
        );
25
    }
26
27
}
28