Skip to content

Commit ad4df49

Browse files
Merge pull request #25 from WikibaseSolutions/valid-identifier
Make sure identifier starts with letter
2 parents 424638e + 7ac8f72 commit ad4df49

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/Variable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,6 @@ public function toQuery(): string
157157
*/
158158
private static function generateUUID(int $length): string
159159
{
160-
return substr(bin2hex(openssl_random_pseudo_bytes(ceil($length / 2))), 0, $length);
160+
return 'var' . substr(bin2hex(openssl_random_pseudo_bytes(ceil($length / 2))), 0, $length);
161161
}
162162
}

tests/Unit/Patterns/NodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function testPropertyWithoutName()
204204
{
205205
$node = new Node();
206206

207-
$this->assertMatchesRegularExpression("/^[0-9a-f]+\.foo$/", $node->property('foo')->toQuery());
207+
$this->assertMatchesRegularExpression("/^var[0-9a-f]+\.foo$/", $node->property('foo')->toQuery());
208208
}
209209

210210
public function provideOnlyLabelData(): array

tests/Unit/QueryTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function testVariableEmpty()
9696
{
9797
$this->assertInstanceOf(Variable::class, Query::variable());
9898

99-
$this->assertMatchesRegularExpression('/[0-9a-f]+/', Query::variable()->toQuery());
99+
$this->assertMatchesRegularExpression('/var[0-9a-f]+/', Query::variable()->toQuery());
100100
}
101101

102102
public function testParameter()
@@ -241,7 +241,7 @@ public function testReturningWithNode()
241241

242242
$statement = (new Query())->returning($node)->build();
243243

244-
$this->assertMatchesRegularExpression("/(RETURN [0-9a-f]+)/", $statement);
244+
$this->assertMatchesRegularExpression("/(RETURN var[0-9a-f]+)/", $statement);
245245

246246
$node = Query::node("m");
247247
$node->named('example');
@@ -408,7 +408,7 @@ public function testWithWithNode()
408408

409409
$statement = (new Query())->with($node)->build();
410410

411-
$this->assertMatchesRegularExpression("/(WITH [0-9a-f]+)/", $statement);
411+
$this->assertMatchesRegularExpression("/(WITH var[0-9a-f]+)/", $statement);
412412

413413
$node = Query::node("m");
414414
$node->named('example');
@@ -886,7 +886,7 @@ public function testAutomaticIdentifierGeneration()
886886
{
887887
$node = Query::node();
888888

889-
$this->assertMatchesRegularExpression('/[0-9a-f]+\.foo/', $node->property('foo')->toQuery());
889+
$this->assertMatchesRegularExpression('/var[0-9a-f]+\.foo/', $node->property('foo')->toQuery());
890890

891891
$node->named('foo');
892892

@@ -895,7 +895,7 @@ public function testAutomaticIdentifierGeneration()
895895
$node = Query::node();
896896
$statement = Query::new()->match($node)->returning($node)->build();
897897

898-
$this->assertMatchesRegularExpression('/MATCH \([0-9a-f]+\) RETURN [0-9a-f]+/', $statement);
898+
$this->assertMatchesRegularExpression('/MATCH \(var[0-9a-f]+\) RETURN var[0-9a-f]+/', $statement);
899899

900900
$node = Query::node();
901901

tests/Unit/VariableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public function testEmptyConstructor()
4646
{
4747
$variable = new Variable();
4848

49-
$this->assertMatchesRegularExpression('/[0-9a-f]+/', $variable->toQuery());
49+
$this->assertMatchesRegularExpression('/var[0-9a-f]+/', $variable->toQuery());
5050

5151
$variable = new Variable(null);
5252

53-
$this->assertMatchesRegularExpression('/[0-9a-f]+/', $variable->toQuery());
53+
$this->assertMatchesRegularExpression('/var[0-9a-f]+/', $variable->toQuery());
5454
}
5555

5656
/**

0 commit comments

Comments
 (0)