Bolt\Tests\Storage\Query\QueryParameterParserTest::testAddingCustomMatcher PHP Method

testAddingCustomMatcher() public method

    public function testAddingCustomMatcher()
    {
        $app = $this->getApp();
        $expr = $app['storage']->createExpressionBuilder();
        // In this test we'll make a custom matcher that allows a new syntax: username: '~test' as an alias for a like query
        $p = new QueryParameterParser($expr);
        $p->addValueMatcher('\\~(\\w+)', ['value' => '%$1%', 'operator' => 'like'], true);
        $filter = $p->getFilter('username', '~test');
        $this->assertEquals('username LIKE :username_1', $filter->getExpression());
        $this->assertEquals(['%test%'], array_values($filter->getParameters()));
    }