Skip to content

Commit f308ed1

Browse files
committed
added skip clause tests
1 parent be4b7c2 commit f308ed1

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

src/Clauses/SkipClause.php

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

4040
/**
4141
* Sets the expression that returns the skip.

tests/Unit/Clauses/SkipClauseTest.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
/*
4+
* Cypher DSL
5+
* Copyright (C) 2021 Wikibase Solutions
6+
*
7+
* This program is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU General Public License
9+
* as published by the Free Software Foundation; either version 2
10+
* of the License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20+
*/
21+
22+
namespace WikibaseSolutions\CypherDSL\Tests\Unit\Clauses;
23+
24+
use PHPUnit\Framework\TestCase;
25+
use TypeError;
26+
use WikibaseSolutions\CypherDSL\Clauses\LimitClause;
27+
use WikibaseSolutions\CypherDSL\Clauses\SkipClause;
28+
use WikibaseSolutions\CypherDSL\Tests\Unit\TestHelper;
29+
use WikibaseSolutions\CypherDSL\Types\AnyType;
30+
use WikibaseSolutions\CypherDSL\Types\PropertyTypes\NumeralType;
31+
32+
/**
33+
* @covers \WikibaseSolutions\CypherDSL\Clauses\LimitClause
34+
*/
35+
class SkipClauseTest extends TestCase
36+
{
37+
use TestHelper;
38+
39+
public function testEmptyClause(): void
40+
{
41+
$skip = new SkipClause();
42+
43+
$this->assertSame("", $skip->toQuery());
44+
$this->assertNull($skip->getSkip());
45+
}
46+
47+
public function testPattern(): void
48+
{
49+
$skip = new SkipClause();
50+
$expression = $this->getQueryConvertableMock(NumeralType::class, "10");
51+
52+
$skip->setSkip($expression);
53+
54+
$this->assertSame("SKIP 10", $skip->toQuery());
55+
$this->assertEquals($expression, $skip->getSkip());
56+
}
57+
58+
/**
59+
* @doesNotPerformAssertions
60+
*/
61+
public function testAcceptsNumeralType(): void
62+
{
63+
$skip = new SkipClause();
64+
$expression = $this->getQueryConvertableMock(NumeralType::class, "10");
65+
66+
$skip->setSkip($expression);
67+
68+
$skip->toQuery();
69+
}
70+
71+
public function testDoesNotAcceptAnyType(): void
72+
{
73+
$skip = new SkipClause();
74+
$expression = $this->getQueryConvertableMock(AnyType::class, "10");
75+
76+
$this->expectException(TypeError::class);
77+
78+
$skip->setSkip($expression);
79+
80+
$skip->toQuery();
81+
}
82+
}

0 commit comments

Comments
 (0)