Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cover unknown constants in tests #400

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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): 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);
}
}