Skip to content

Commit ccf7deb

Browse files
committed
expanded all clause tests
1 parent 289228a commit ccf7deb

15 files changed

+232
-120
lines changed

src/Clauses/LimitClause.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class LimitClause extends Clause
3535
*
3636
* @var NumeralType|null $limit
3737
*/
38-
private ?NumeralType $limit;
38+
private ?NumeralType $limit = null;
3939

4040
/**
4141
* Returns the actual limit of the clause.

src/Clauses/MergeClause.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ class MergeClause extends Clause
3737
/**
3838
* @var StructuralType|Assignment|null $pattern The pattern to merge
3939
*/
40-
private $pattern;
40+
private $pattern = null;
4141

4242
/**
4343
* @var Clause|null $createClause The clause to execute when the pattern is created
4444
*/
45-
private ?Clause $createClause;
45+
private ?Clause $createClause = null;
4646

4747
/**
4848
* @var Clause|null $matchClause The clause to execute when the pattern is matched
4949
*/
50-
private ?Clause $matchClause;
50+
private ?Clause $matchClause = null;
5151

5252
/**
5353
* Returns the clause to execute when the pattern is matched.

src/Clauses/WhereClause.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class WhereClause extends Clause
3535
/**
3636
* @var BooleanType|Label|null The expression to match
3737
*/
38-
private ?AnyType $expression;
38+
private ?AnyType $expression = null;
3939

4040
/**
4141
* Sets the expression to match in this WHERE clause.

tests/Unit/Clauses/DeleteClauseTest.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,28 @@ class DeleteClauseTest extends TestCase
3535
{
3636
use TestHelper;
3737

38-
public function testEmptyClause()
38+
public function testEmptyClause(): void
3939
{
4040
$delete = new DeleteClause();
4141

4242
$this->assertSame("", $delete->toQuery());
43+
$this->assertEquals([], $delete->getNodes());
44+
$this->assertFalse($delete->detachesDeletion());
4345
}
4446

45-
public function testSingleNode()
47+
public function testSingleNode(): void
4648
{
4749
$delete = new DeleteClause();
4850
$node = $this->getQueryConvertableMock(NodeType::class, "(a)");
4951

5052
$delete->addNode($node);
5153

5254
$this->assertSame("DELETE (a)", $delete->toQuery());
55+
$this->assertEquals([$node], $delete->getNodes());
56+
$this->assertFalse($delete->detachesDeletion());
5357
}
5458

55-
public function testMultipleNodes()
59+
public function testMultipleNodes(): void
5660
{
5761
$delete = new DeleteClause();
5862

@@ -63,9 +67,11 @@ public function testMultipleNodes()
6367
$delete->addNode($b);
6468

6569
$this->assertSame("DELETE (a), (b)", $delete->toQuery());
70+
$this->assertEquals([$a, $b], $delete->getNodes());
71+
$this->assertFalse($delete->detachesDeletion());
6672
}
6773

68-
public function testDetachDelete()
74+
public function testDetachDelete(): void
6975
{
7076
$delete = new DeleteClause();
7177
$pattern = $this->getQueryConvertableMock(NodeType::class, "(a)");
@@ -74,21 +80,22 @@ public function testDetachDelete()
7480
$delete->setDetach(true);
7581

7682
$this->assertSame("DETACH DELETE (a)", $delete->toQuery());
83+
$this->assertEquals([$pattern], $delete->getNodes());
84+
$this->assertTrue($delete->detachesDeletion());
7785
}
7886

79-
/**
80-
* @doesNotPerformAssertions
81-
*/
82-
public function testAcceptsNodeType()
87+
public function testAcceptsNodeType(): void
8388
{
8489
$delete = new DeleteClause();
8590
$pattern = $this->getQueryConvertableMock(NodeType::class, "(a)");
8691

8792
$delete->addNode($pattern);
8893
$delete->toQuery();
94+
$this->assertEquals([$pattern], $delete->getNodes());
95+
$this->assertFalse($delete->detachesDeletion());
8996
}
9097

91-
public function testDoesNotAcceptAnyType()
98+
public function testDoesNotAcceptAnyType(): void
9299
{
93100
$delete = new DeleteClause();
94101
$pattern = $this->getQueryConvertableMock(AnyType::class, "(a)");

tests/Unit/Clauses/LimitClauseTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,37 @@ class LimitClauseTest extends TestCase
3535
{
3636
use TestHelper;
3737

38-
public function testEmptyClause()
38+
public function testEmptyClause(): void
3939
{
4040
$limit = new LimitClause();
4141

4242
$this->assertSame("", $limit->toQuery());
43+
$this->assertNull($limit->getLimit());
4344
}
4445

45-
public function testPattern()
46+
public function testPattern(): void
4647
{
4748
$limit = new LimitClause();
4849
$expression = $this->getQueryConvertableMock(NumeralType::class, "10");
4950

5051
$limit->setLimit($expression);
5152

5253
$this->assertSame("LIMIT 10", $limit->toQuery());
54+
$this->assertEquals($expression, $limit->getLimit());
5355
}
5456

55-
/**
56-
* @doesNotPerformAssertions
57-
*/
58-
public function testAcceptsNumeralType()
57+
public function testAcceptsNumeralType(): void
5958
{
6059
$limit = new LimitClause();
6160
$expression = $this->getQueryConvertableMock(NumeralType::class, "10");
6261

6362
$limit->setLimit($expression);
6463

6564
$limit->toQuery();
65+
$this->assertEquals($expression, $limit->getLimit());
6666
}
6767

68-
public function testDoesNotAcceptAnyType()
68+
public function testDoesNotAcceptAnyType(): void
6969
{
7070
$limit = new LimitClause();
7171
$expression = $this->getQueryConvertableMock(AnyType::class, "10");

tests/Unit/Clauses/MatchClauseTest.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,41 @@ class MatchClauseTest extends TestCase
3838
{
3939
use TestHelper;
4040

41-
public function testEmptyClause()
41+
public function testEmptyClause(): void
4242
{
4343
$match = new MatchClause();
4444

4545
$this->assertSame("", $match->toQuery());
46+
$this->assertEquals([], $match->getPatterns());
4647
}
4748

48-
public function testSinglePattern()
49+
public function testSinglePattern(): void
4950
{
5051
$match = new MatchClause();
51-
$match->addPattern($this->getQueryConvertableMock(StructuralType::class, "(a)"));
52+
$pattern = $this->getQueryConvertableMock(StructuralType::class, "(a)");
53+
$match->addPattern($pattern);
5254

5355
$this->assertSame("MATCH (a)", $match->toQuery());
56+
$this->assertEquals([$pattern], $match->getPatterns());
5457
}
5558

56-
public function testMultiplePatterns()
59+
public function testMultiplePatterns(): void
5760
{
5861
$match = new MatchClause();
59-
$match->addPattern($this->getQueryConvertableMock(StructuralType::class, "(a)"));
60-
$match->addPattern($this->getQueryConvertableMock(StructuralType::class, "(b)"));
62+
$patternA = $this->getQueryConvertableMock(StructuralType::class, "(a)");
63+
$patternB = $this->getQueryConvertableMock(StructuralType::class, "(b)");
64+
65+
$match->addPattern($patternA);
66+
$match->addPattern($patternB);
6167

6268
$this->assertSame("MATCH (a), (b)", $match->toQuery());
69+
$this->assertEquals([$patternA, $patternB], $match->getPatterns());
6370
}
6471

6572
/**
6673
* @doesNotPerformAssertions
6774
*/
68-
public function testAcceptsNodeType()
75+
public function testAcceptsNodeType(): void
6976
{
7077
$match = new MatchClause();
7178
$match->addPattern($this->getQueryConvertableMock(NodeType::class, "(a)"));
@@ -76,7 +83,7 @@ public function testAcceptsNodeType()
7683
/**
7784
* @doesNotPerformAssertions
7885
*/
79-
public function testAcceptsPathType()
86+
public function testAcceptsPathType(): void
8087
{
8188
$match = new MatchClause();
8289
$match->addPattern($this->getQueryConvertableMock(PathType::class, "(a)"));
@@ -87,7 +94,7 @@ public function testAcceptsPathType()
8794
/**
8895
* @doesNotPerformAssertions
8996
*/
90-
public function testAcceptsAssignment()
97+
public function testAcceptsAssignment(): void
9198
{
9299
$match = new MatchClause();
93100

@@ -96,7 +103,7 @@ public function testAcceptsAssignment()
96103
$match->toQuery();
97104
}
98105

99-
public function testDoesNotAcceptAnyType()
106+
public function testDoesNotAcceptAnyType(): void
100107
{
101108
$this->expectException(TypeError::class);
102109

tests/Unit/Clauses/MergeClauseTest.php

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,30 @@ class MergeClauseTest extends TestCase
3939
{
4040
use TestHelper;
4141

42-
public function testEmptyClause()
42+
public function testEmptyClause(): void
4343
{
4444
$merge = new MergeClause();
4545

4646
$this->assertSame("", $merge->toQuery());
47+
$this->assertNull($merge->getOnCreateClause());
48+
$this->assertNull($merge->getPattern());
49+
$this->assertNull($merge->getOnMatchClause());
4750
}
4851

49-
public function testPattern()
52+
public function testPattern(): void
5053
{
5154
$merge = new MergeClause();
5255
$pattern = $this->getQueryConvertableMock(StructuralType::class, "(a)");
5356

5457
$merge->setPattern($pattern);
5558

5659
$this->assertSame("MERGE (a)", $merge->toQuery());
60+
$this->assertNull($merge->getOnCreateClause());
61+
$this->assertEquals($pattern, $merge->getPattern());
62+
$this->assertNull($merge->getOnMatchClause());
5763
}
5864

59-
public function testSetOnCreate()
65+
public function testSetOnCreate(): void
6066
{
6167
$merge = new MergeClause();
6268

@@ -67,9 +73,12 @@ public function testSetOnCreate()
6773
$merge->setOnCreate($clause);
6874

6975
$this->assertSame("MERGE (a) ON CREATE SET a = 10", $merge->toQuery());
76+
$this->assertEquals($clause, $merge->getOnCreateClause());
77+
$this->assertEquals($pattern, $merge->getPattern());
78+
$this->assertNull($merge->getOnMatchClause());
7079
}
7180

72-
public function testSetOnMatch()
81+
public function testSetOnMatch(): void
7382
{
7483
$merge = new MergeClause();
7584

@@ -80,9 +89,12 @@ public function testSetOnMatch()
8089
$merge->setOnMatch($clause);
8190

8291
$this->assertSame("MERGE (a) ON MATCH SET a = 10", $merge->toQuery());
92+
$this->assertNull($merge->getOnCreateClause());
93+
$this->assertEquals($pattern, $merge->getPattern());
94+
$this->assertEquals($clause, $merge->getOnMatchClause());
8395
}
8496

85-
public function testSetOnBoth()
97+
public function testSetOnBoth(): void
8698
{
8799
$merge = new MergeClause();
88100

@@ -94,12 +106,15 @@ public function testSetOnBoth()
94106
$merge->setOnMatch($clause);
95107

96108
$this->assertSame("MERGE (a) ON CREATE SET a = 10 ON MATCH SET a = 10", $merge->toQuery());
109+
$this->assertEquals($clause, $merge->getOnCreateClause());
110+
$this->assertEquals($pattern, $merge->getPattern());
111+
$this->assertEquals($clause, $merge->getOnMatchClause());
97112
}
98113

99114
/**
100115
* @doesNotPerformAssertions
101116
*/
102-
public function testAcceptsNodeType()
117+
public function testAcceptsNodeType(): void
103118
{
104119
$merge = new MergeClause();
105120
$pattern = $this->getQueryConvertableMock(NodeType::class, "(a)");
@@ -112,7 +127,7 @@ public function testAcceptsNodeType()
112127
/**
113128
* @doesNotPerformAssertions
114129
*/
115-
public function testAcceptsPathType()
130+
public function testAcceptsPathType(): void
116131
{
117132
$merge = new MergeClause();
118133
$pattern = $this->getQueryConvertableMock(PathType::class, "(a)");
@@ -125,7 +140,7 @@ public function testAcceptsPathType()
125140
/**
126141
* @doesNotPerformAssertions
127142
*/
128-
public function testAcceptsAssignment()
143+
public function testAcceptsAssignment(): void
129144
{
130145
$merge = new MergeClause();
131146
$pattern = $this->getQueryConvertableMock(Assignment::class, "p = (a)-->(b)");
@@ -135,7 +150,7 @@ public function testAcceptsAssignment()
135150
$merge->toQuery();
136151
}
137152

138-
public function testDoesNotAcceptAnyType()
153+
public function testDoesNotAcceptAnyType(): void
139154
{
140155
$merge = new MergeClause();
141156
$pattern = $this->getQueryConvertableMock(AnyType::class, "(a)");

0 commit comments

Comments
 (0)