Skip to content

Commit d33329a

Browse files
committed
added tests for literal factory methods in expression list
1 parent 66e8aa9 commit d33329a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

tests/Unit/ExpressionListTest.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace WikibaseSolutions\CypherDSL\Tests\Unit;
2323

2424
use PHPUnit\Framework\TestCase;
25+
use TypeError;
2526
use WikibaseSolutions\CypherDSL\ExpressionList;
2627
use WikibaseSolutions\CypherDSL\Query;
2728

@@ -32,19 +33,33 @@ class ExpressionListTest extends TestCase
3233
{
3334
use TestHelper;
3435

35-
public function testEmpty()
36+
public function testEmpty(): void
3637
{
3738
$expressionList = new ExpressionList([]);
3839

3940
$this->assertSame("[]", $expressionList->toQuery());
4041
}
4142

43+
public function testFromLiterals(): void
44+
{
45+
$expressionList = ExpressionList::fromLiterals(['a', 'b', 234.3, 1, true, false]);
46+
47+
$this->assertSame("['a', 'b', 234.3, 1, true, false]", $expressionList->toQuery());
48+
}
49+
50+
public function testFromLiteralsError(): void
51+
{
52+
$expressionList = ExpressionList::fromLiterals(['a', 'b', 234.3, 1, true, false]);
53+
$this->expectException(TypeError::class);
54+
$expressionList = ExpressionList::fromLiterals([$expressionList]);
55+
}
56+
4257
/**
4358
* @dataProvider provideOneDimensionalData
4459
* @param array $expressions
4560
* @param string $expected
4661
*/
47-
public function testOneDimensional(array $expressions, string $expected)
62+
public function testOneDimensional(array $expressions, string $expected): void
4863
{
4964
$expressionList = new ExpressionList($expressions);
5065

@@ -56,7 +71,7 @@ public function testOneDimensional(array $expressions, string $expected)
5671
* @param array $expressions
5772
* @param string $expected
5873
*/
59-
public function testMultidimensional(array $expressions, string $expected)
74+
public function testMultidimensional(array $expressions, string $expected): void
6075
{
6176
$expressionList = new ExpressionList($expressions);
6277

0 commit comments

Comments
 (0)