Skip to content

Commit

Permalink
cover unknown constants in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clxmstaab authored and staabm committed Sep 25, 2022
1 parent d73bbb7 commit 6416234
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/rules/data/query-plan-analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public function unknownQuery(Connection $conn, string $query): void

public function nonSimulatableQuery(Connection $conn, $email): void
{
$conn->executeQuery('SELECT * FROM ada WHERE email = '.$email);
$conn->executeQuery('SELECT * FROM ada WHERE email = ' . $email);
}

public function unknownConstant(Connection $conn, int $adaidl): void
{
$conn->executeQuery('SELECT * FROM ada WHERE adaid = ?', [CONSTANT_DOES_NOT_EXIST]);
}
}
5 changes: 5 additions & 0 deletions tests/rules/data/syntax-error-in-prepared-statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,9 @@ public function preparedNamedParamsSubstitution(Connection $connection)
{
$connection->preparedQuery('SELECT email FROM ada WHERE email = :param OR email = :parameter', ['param' => 'abc', 'parameter' => 'def']);
}

public function unknownConstant(Connection $connection)
{
$connection->preparedQuery('SELECT email FROM ada WHERE email = :param OR email = :parameter', ['param' => CONSTANT_DOES_NOT_EXIST, 'parameter' => 'def']);
}
}
5 changes: 5 additions & 0 deletions tests/rules/data/syntax-error-in-query-method.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,9 @@ public function conditionalSyntaxErrorInQueryUnion(PDO $pdo)

$pdo->query('SELECT email, adaid FROM ada '.$add.' LIMIT 1', PDO::FETCH_ASSOC);
}

public function unknownConstant(PDO $pdo)
{
$pdo->query('SELECT * FROM ada WHERE doesNotExist='.CONSTANT_DOES_NOT_EXIST, PDO::FETCH_ASSOC);
}
}

0 comments on commit 6416234

Please sign in to comment.