summaryrefslogtreecommitdiffstats
path: root/tests/Components
diff options
context:
space:
mode:
authorThomas Gerbet <thomas@gerbet.me>2019-04-10 22:51:51 +0200
committerThomas Gerbet <thomas@gerbet.me>2019-04-10 23:12:31 +0200
commitb47e27b8724cb2639cccec9430076ef8a68c869c (patch)
tree6a4ff6c9d796b77f14b7112f87f706e16b4523ae /tests/Components
parent9f088cd04b29665db0a1ffd138130a1437fe07b1 (diff)
downloadsql-parser-b47e27b8724cb2639cccec9430076ef8a68c869c.zip
sql-parser-b47e27b8724cb2639cccec9430076ef8a68c869c.tar.gz
sql-parser-b47e27b8724cb2639cccec9430076ef8a68c869c.tar.bz2
Fix PHP warnings when building an incomplete CASE expression
Issue can be reproduced with the following code snippet: ```php new \PhpMyAdmin\SqlParser\Parser('SELECT a CASE'); // PHP Warning: count(): Parameter must be an array or an object that implements Countable in src/Components/CaseExpression.php on line 296 // PHP Warning: count(): Parameter must be an array or an object that implements Countable in src/Components/CaseExpression.php on line 297 ```
Diffstat (limited to 'tests/Components')
-rw-r--r--tests/Components/CaseExpressionTest.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/Components/CaseExpressionTest.php b/tests/Components/CaseExpressionTest.php
index cb9290c..2ea8f8b 100644
--- a/tests/Components/CaseExpressionTest.php
+++ b/tests/Components/CaseExpressionTest.php
@@ -118,4 +118,10 @@ class CaseExpressionTest extends TestCase
'CASE WHEN 1=1 THEN "Some" WHEN 1=2 THEN "SomeOther" END AS `foo`'
);
}
+
+ public function testBuildWithIncompleteCaseExpression()
+ {
+ $incomplete_case_expression_component = new CaseExpression();
+ $this->assertEquals('CASE END', CaseExpression::build($incomplete_case_expression_component));
+ }
}