|
| 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