Skip to content

Commit 65de8c2

Browse files
committed
more tests
1 parent f41a8d7 commit 65de8c2

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

tests/rules/SyntaxErrorInPreparedStatementMethodRuleTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,15 @@ public function testSyntaxErrorWithInferencePlaceholder()
335335

336336
public function testBug749(): void
337337
{
338-
$this->analyse([__DIR__ . '/data/bug-749.php'], []);
338+
$this->analyse([__DIR__ . '/data/bug-749.php'], [
339+
[
340+
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'table WHERE err-or id IN ('1') LIMIT 0' at line 1 (1064).",
341+
16
342+
],
343+
[
344+
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'table WHERE a='1970-01-01' AND err-or id IN ('1') LIMIT 0' at line 1 (1064).",
345+
30
346+
]
347+
]);
339348
}
340349
}

tests/rules/data/bug-749.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ public function getIds(array $ids): array
2222
->fetchFirstColumn();
2323
}
2424

25+
/**
26+
* @param array<int> $ids
27+
*/
28+
public function getMoreIds(string $s, array $ids): array
29+
{
30+
return $this
31+
->connection
32+
->executeQuery(
33+
'SELECT id FROM table WHERE a=? AND err-or id IN ('. self::inPlaceholders($ids) .')',
34+
[
35+
$s,
36+
...$ids
37+
],
38+
)
39+
->fetchFirstColumn();
40+
}
41+
2542
/**
2643
* Returns a string containing all required "?"-placeholders to pass $ids into a IN()-expression.
2744
*

0 commit comments

Comments
 (0)