Skip to content

Commit e3e641e

Browse files
author
Wout Gevaert
committed
Move tests to correctly named file
1 parent 9d29367 commit e3e641e

File tree

4 files changed

+154
-89
lines changed

4 files changed

+154
-89
lines changed

src/Equality.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
use WikibaseSolutions\CypherDSL\Traits\BooleanTypeTrait;
2525
use WikibaseSolutions\CypherDSL\Traits\ErrorTrait;
2626
use WikibaseSolutions\CypherDSL\Types\AnyType;
27+
use WikibaseSolutions\CypherDSL\Types\CompositeTypes\CompositeType;
2728
use WikibaseSolutions\CypherDSL\Types\PropertyTypes\BooleanType;
2829
use WikibaseSolutions\CypherDSL\Types\PropertyTypes\PropertyType;
29-
use WikibaseSolutions\CypherDSL\Types\CompositeTypes\CompositeType;
3030

3131
/**
3232
* Represents the application of the equality (=) operator.

src/Traits/ComparableTypeTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*/
3333
trait ComparableTypeTrait
3434
{
35+
use PropertyTypeTrait;
36+
3537
/**
3638
* Perform a greater than comparison against the given expression.
3739
*
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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\Traits;
23+
24+
use PHPUnit\Framework\MockObject\MockObject;
25+
use PHPUnit\Framework\TestCase;
26+
use WikibaseSolutions\CypherDSL\GreaterThan;
27+
use WikibaseSolutions\CypherDSL\GreaterThanOrEqual;
28+
use WikibaseSolutions\CypherDSL\LessThan;
29+
use WikibaseSolutions\CypherDSL\LessThanOrEqual;
30+
use WikibaseSolutions\CypherDSL\Tests\Unit\TestHelper;
31+
use WikibaseSolutions\CypherDSL\Traits\ComparableTypeTrait;
32+
use WikibaseSolutions\CypherDSL\Types\PropertyTypes\ComparableType;
33+
34+
/**
35+
* @covers \WikibaseSolutions\CypherDSL\Traits\NumeralTypeTrait
36+
*/
37+
class ComparableTypeTraitTest extends TestCase
38+
{
39+
use TestHelper;
40+
41+
/**
42+
* @var MockObject|ComparableType
43+
*/
44+
private $a;
45+
46+
/**
47+
* @var MockObject|ComparableType
48+
*/
49+
private $b;
50+
51+
public function setUp(): void
52+
{
53+
$this->a = new class () implements ComparableType {
54+
use ComparableTypeTrait;
55+
56+
public function toQuery(): string
57+
{
58+
return '10';
59+
}
60+
};
61+
$this->b = $this->getQueryConvertableMock(ComparableType::class, "date({year: 2020, month: 12, day: 5})");
62+
}
63+
64+
public function testGt(): void
65+
{
66+
$gt = $this->a->gt($this->b);
67+
68+
$this->assertInstanceOf(GreaterThan::class, $gt);
69+
70+
$this->assertTrue($gt->insertsParentheses());
71+
$this->assertEquals($this->a, $gt->getLeft());
72+
$this->assertEquals($this->b, $gt->getRight());
73+
}
74+
75+
public function testGtNoParentheses(): void
76+
{
77+
$gt = $this->a->gt($this->b, false);
78+
79+
$this->assertInstanceOf(GreaterThan::class, $gt);
80+
81+
$this->assertFalse($gt->insertsParentheses());
82+
$this->assertEquals($this->a, $gt->getLeft());
83+
$this->assertEquals($this->b, $gt->getRight());
84+
}
85+
86+
public function testGte(): void
87+
{
88+
$gte = $this->a->gte($this->b);
89+
90+
$this->assertInstanceOf(GreaterThanOrEqual::class, $gte);
91+
92+
$this->assertTrue($gte->insertsParentheses());
93+
$this->assertEquals($this->a, $gte->getLeft());
94+
$this->assertEquals($this->b, $gte->getRight());
95+
}
96+
97+
public function testGteNoParentheses(): void
98+
{
99+
$gte = $this->a->gte($this->b, false);
100+
101+
$this->assertInstanceOf(GreaterThanOrEqual::class, $gte);
102+
103+
$this->assertFalse($gte->insertsParentheses());
104+
$this->assertEquals($this->a, $gte->getLeft());
105+
$this->assertEquals($this->b, $gte->getRight());
106+
}
107+
108+
public function testLt(): void
109+
{
110+
$lt = $this->a->lt($this->b);
111+
112+
$this->assertInstanceOf(LessThan::class, $lt);
113+
114+
$this->assertTrue($lt->insertsParentheses());
115+
$this->assertEquals($this->a, $lt->getLeft());
116+
$this->assertEquals($this->b, $lt->getRight());
117+
}
118+
119+
public function testLtNoParentheses(): void
120+
{
121+
$lt = $this->a->lt($this->b, false);
122+
123+
$this->assertInstanceOf(LessThan::class, $lt);
124+
125+
$this->assertFalse($lt->insertsParentheses());
126+
$this->assertEquals($this->a, $lt->getLeft());
127+
$this->assertEquals($this->b, $lt->getRight());
128+
}
129+
130+
public function testLte(): void
131+
{
132+
$lte = $this->a->lte($this->b);
133+
134+
$this->assertInstanceOf(LessThanOrEqual::class, $lte);
135+
136+
$this->assertTrue($lte->insertsParentheses());
137+
$this->assertEquals($this->a, $lte->getLeft());
138+
$this->assertEquals($this->b, $lte->getRight());
139+
}
140+
141+
public function testLteNoParentheses(): void
142+
{
143+
$lte = $this->a->lte($this->b, false);
144+
145+
$this->assertInstanceOf(LessThanOrEqual::class, $lte);
146+
147+
$this->assertFalse($lte->insertsParentheses());
148+
$this->assertEquals($this->a, $lte->getLeft());
149+
$this->assertEquals($this->b, $lte->getRight());
150+
}
151+
}

tests/Unit/Traits/NumeralTypeTraitTest.php

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -134,94 +134,6 @@ public function testExponentiateNoParentheses(): void
134134
$this->assertEquals($this->b, $exponentiate->getRight());
135135
}
136136

137-
public function testGt(): void
138-
{
139-
$gt = $this->a->gt($this->b);
140-
141-
$this->assertInstanceOf(GreaterThan::class, $gt);
142-
143-
$this->assertTrue($gt->insertsParentheses());
144-
$this->assertEquals($this->a, $gt->getLeft());
145-
$this->assertEquals($this->b, $gt->getRight());
146-
}
147-
148-
public function testGtNoParentheses(): void
149-
{
150-
$gt = $this->a->gt($this->b, false);
151-
152-
$this->assertInstanceOf(GreaterThan::class, $gt);
153-
154-
$this->assertFalse($gt->insertsParentheses());
155-
$this->assertEquals($this->a, $gt->getLeft());
156-
$this->assertEquals($this->b, $gt->getRight());
157-
}
158-
159-
public function testGte(): void
160-
{
161-
$gte = $this->a->gte($this->b);
162-
163-
$this->assertInstanceOf(GreaterThanOrEqual::class, $gte);
164-
165-
$this->assertTrue($gte->insertsParentheses());
166-
$this->assertEquals($this->a, $gte->getLeft());
167-
$this->assertEquals($this->b, $gte->getRight());
168-
}
169-
170-
public function testGteNoParentheses(): void
171-
{
172-
$gte = $this->a->gte($this->b, false);
173-
174-
$this->assertInstanceOf(GreaterThanOrEqual::class, $gte);
175-
176-
$this->assertFalse($gte->insertsParentheses());
177-
$this->assertEquals($this->a, $gte->getLeft());
178-
$this->assertEquals($this->b, $gte->getRight());
179-
}
180-
181-
public function testLt(): void
182-
{
183-
$lt = $this->a->lt($this->b);
184-
185-
$this->assertInstanceOf(LessThan::class, $lt);
186-
187-
$this->assertTrue($lt->insertsParentheses());
188-
$this->assertEquals($this->a, $lt->getLeft());
189-
$this->assertEquals($this->b, $lt->getRight());
190-
}
191-
192-
public function testLtNoParentheses(): void
193-
{
194-
$lt = $this->a->lt($this->b, false);
195-
196-
$this->assertInstanceOf(LessThan::class, $lt);
197-
198-
$this->assertFalse($lt->insertsParentheses());
199-
$this->assertEquals($this->a, $lt->getLeft());
200-
$this->assertEquals($this->b, $lt->getRight());
201-
}
202-
203-
public function testLte(): void
204-
{
205-
$lte = $this->a->lte($this->b);
206-
207-
$this->assertInstanceOf(LessThanOrEqual::class, $lte);
208-
209-
$this->assertTrue($lte->insertsParentheses());
210-
$this->assertEquals($this->a, $lte->getLeft());
211-
$this->assertEquals($this->b, $lte->getRight());
212-
}
213-
214-
public function testLteNoParentheses(): void
215-
{
216-
$lte = $this->a->lte($this->b, false);
217-
218-
$this->assertInstanceOf(LessThanOrEqual::class, $lte);
219-
220-
$this->assertFalse($lte->insertsParentheses());
221-
$this->assertEquals($this->a, $lte->getLeft());
222-
$this->assertEquals($this->b, $lte->getRight());
223-
}
224-
225137
public function testMod(): void
226138
{
227139
$mod = $this->a->mod($this->b);

0 commit comments

Comments
 (0)