public function testQueryBuildWithFieldKey()
 {
     $query_context = $this->prophesize(QueryContext::class)->reveal();
     $key = $this->prophesize(FieldKey::class);
     $key->getIndexField($query_context)->willReturn('baz');
     $key->isValueCompatible('bar', $query_context)->willReturn(true);
     $key->postProcessQuery(Argument::any(), $query_context)->willReturnArgument(0);
     $node = RangeExpression::lessThan($key->reveal(), 'bar');
     $query = $node->buildQuery($query_context);
     $expected = '{
         "range": {
             "baz": {
                 "lt": "bar"
             }
         }
     }';
     $this->assertEquals(json_decode($expected, true), $query);
 }
 private function visitRangeNode(TreeNode $node)
 {
     $this->assertChildrenCount($node, 2);
     $key = $node->getChild(0)->accept($this);
     $boundary = $node->getChild(1)->accept($this);
     switch ($node->getId()) {
         case NodeTypes::LT_EXPR:
             return AST\KeyValue\RangeExpression::lessThan($key, $boundary);
         case NodeTypes::LTE_EXPR:
             return AST\KeyValue\RangeExpression::lessThanOrEqual($key, $boundary);
         case NodeTypes::GT_EXPR:
             return AST\KeyValue\RangeExpression::greaterThan($key, $boundary);
         case NodeTypes::GTE_EXPR:
             return AST\KeyValue\RangeExpression::greaterThanOrEqual($key, $boundary);
     }
 }