Skip to content

Commit fc0e5a2

Browse files
committed
JSON full text maching fixed (#167)
1 parent 300c41a commit fc0e5a2

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/Factory/SimpleFactory.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
class SimpleFactory implements Factory
1313
{
14+
private $parser;
15+
1416
public function createMatcher() : Matcher
1517
{
1618
return new Matcher($this->buildMatchers());
@@ -39,7 +41,8 @@ protected function buildOrMatcher() : Matcher\ChainMatcher
3941
$arrayMatcher = new Matcher\ArrayMatcher(
4042
new Matcher\ChainMatcher([
4143
$orMatcher,
42-
$scalarMatchers
44+
$scalarMatchers,
45+
new Matcher\TextMatcher($scalarMatchers, $this->buildParser())
4346
]),
4447
$this->buildParser()
4548
);
@@ -76,6 +79,12 @@ protected function buildScalarMatchers() : Matcher\ChainMatcher
7679

7780
protected function buildParser() : Parser
7881
{
79-
return new Parser(new Lexer(), new Parser\ExpanderInitializer());
82+
if ($this->parser) {
83+
return $this->parser;
84+
}
85+
86+
$this->parser = new Parser(new Lexer(), new Parser\ExpanderInitializer());
87+
88+
return $this->parser;
8089
}
8190
}

tests/MatcherTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ public function jsonDataProvider()
131131
"nextPage": "@string@"
132132
}',
133133
],
134+
'matches json values with full text matcher' => [
135+
/** @lang JSON */
136+
'{
137+
"url": "/accounts/9a7dae2d-d135-4bd7-b202-b3e7e91aaecd"
138+
}',
139+
/** @lang JSON */
140+
'{
141+
"url": "/accounts/@uuid@"
142+
}',
143+
],
134144
'matches none elements - empty array' => [
135145
/** @lang JSON */
136146
'{

0 commit comments

Comments
 (0)