Skip to content

Commit 386dd55

Browse files
committed
added tests for null comparison operators
1 parent 42b8897 commit 386dd55

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

tests/Unit/IsNotNullTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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;
23+
24+
use PHPUnit\Framework\TestCase;
25+
use WikibaseSolutions\CypherDSL\IsNotNull;
26+
use WikibaseSolutions\CypherDSL\Types\PropertyTypes\BooleanType;
27+
28+
/**
29+
* @covers \WikibaseSolutions\CypherDSL\Not
30+
*/
31+
class IsNotNullTest extends TestCase
32+
{
33+
use TestHelper;
34+
35+
public function testToQuery(): void
36+
{
37+
$not = new IsNotNull($this->getQueryConvertableMock(BooleanType::class, "true"));
38+
39+
$this->assertSame("(true IS NOT NULL)", $not->toQuery());
40+
41+
$not = new IsNotNull($not);
42+
43+
$this->assertSame("((true IS NOT NULL) IS NOT NULL)", $not->toQuery());
44+
}
45+
}

tests/Unit/IsNullTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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;
23+
24+
use PHPUnit\Framework\TestCase;
25+
use WikibaseSolutions\CypherDSL\IsNull;
26+
use WikibaseSolutions\CypherDSL\Types\PropertyTypes\BooleanType;
27+
28+
/**
29+
* @covers \WikibaseSolutions\CypherDSL\Not
30+
*/
31+
class IsNullTest extends TestCase
32+
{
33+
use TestHelper;
34+
35+
public function testToQuery(): void
36+
{
37+
$not = new IsNull($this->getQueryConvertableMock(BooleanType::class, "true"));
38+
39+
$this->assertSame("(true IS NULL)", $not->toQuery());
40+
41+
$not = new IsNull($not);
42+
43+
$this->assertSame("((true IS NULL) IS NULL)", $not->toQuery());
44+
}
45+
}

0 commit comments

Comments
 (0)