-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix query: sequential member access was not resetting method arguments
- Loading branch information
Showing
2 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Kirby\Toolkit\Query; | ||
use Kirby\TestCase; | ||
use Kirby\Toolkit\Query\AST\ArgumentListNode; | ||
use Kirby\Toolkit\Query\AST\LiteralNode; | ||
use Kirby\Toolkit\Query\AST\MemberAccessNode; | ||
use Kirby\Toolkit\Query\AST\VariableNode; | ||
use Kirby\Toolkit\Query\Parser; | ||
use Kirby\Toolkit\Query\Tokenizer; | ||
|
||
class ParserTest extends TestCase { | ||
function testMemberAccess() { | ||
$tokenizer = new Tokenizer('user.name'); | ||
$ast = (new Parser($tokenizer))->parse(); | ||
$this->assertEquals($ast, | ||
new MemberAccessNode( | ||
new VariableNode('user'), 'name' | ||
) | ||
); | ||
} | ||
|
||
function testSquentialMemberAccess() { | ||
$tokenizer = new Tokenizer('user.name("arg").age'); | ||
$ast = (new Parser($tokenizer))->parse(); | ||
$this->assertEquals($ast, | ||
new MemberAccessNode( | ||
new MemberAccessNode( | ||
new VariableNode('user'), | ||
'name', | ||
new ArgumentListNode([new LiteralNode("arg")]) | ||
), | ||
'age' | ||
) | ||
); | ||
} | ||
} |