Skip to content

Commit b5da1d5

Browse files
committed
wip
1 parent ddfc4be commit b5da1d5

File tree

5 files changed

+300
-3
lines changed

5 files changed

+300
-3
lines changed

src/Helper/ToCypherHelper.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,6 @@ public static function indexToCypherString(IndexInterface $index): string
236236
if (null === $index->getType()) {
237237
throw InvalidArgumentException::createForTypeMismatch('string', 'null');
238238
}
239-
if (0 === count($index->getProperties())) {
240-
throw new InvalidArgumentException("At least one property is required");
241-
}
242239

243240
// $for = $index->getFor();
244241
// if ($for instanceof NodeLabelInterface) {

tests/Type/NodeConstraintTest.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Syndesi\CypherDataStructures\Tests\Type;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Syndesi\CypherDataStructures\Type\NodeConstraint;
9+
10+
class NodeConstraintTest extends TestCase
11+
{
12+
public function testIndexIsInitiallyEmpty(): void
13+
{
14+
$nodeConstraint = new NodeConstraint();
15+
$this->assertEmpty($nodeConstraint->getName());
16+
$this->assertEmpty($nodeConstraint->getType());
17+
$this->assertEmpty($nodeConstraint->getFor());
18+
}
19+
20+
public function testName(): void
21+
{
22+
$nodeConstraint = new NodeConstraint();
23+
$this->assertNull($nodeConstraint->getName());
24+
$nodeConstraint->setName('some_name');
25+
$this->assertSame('some_name', $nodeConstraint->getName());
26+
$nodeConstraint->setName(null);
27+
$this->assertNull($nodeConstraint->getName());
28+
}
29+
30+
public function testType(): void
31+
{
32+
$nodeConstraint = new NodeConstraint();
33+
$this->assertNull($nodeConstraint->getType());
34+
$nodeConstraint->setType('SOME_TYPE');
35+
$this->assertSame('SOME_TYPE', $nodeConstraint->getType());
36+
$nodeConstraint->setType(null);
37+
$this->assertNull($nodeConstraint->getType());
38+
}
39+
40+
public function testFor(): void
41+
{
42+
$nodeConstraint = new NodeConstraint();
43+
$this->assertNull($nodeConstraint->getFor());
44+
$nodeConstraint->setFor('SomeNodeLabel');
45+
$this->assertSame('SomeNodeLabel', $nodeConstraint->getFor());
46+
$nodeConstraint->setFor(null);
47+
$this->assertNull($nodeConstraint->getFor());
48+
}
49+
50+
public function testToString(): void
51+
{
52+
$nodeConstraint = (new NodeConstraint())
53+
->setName('name')
54+
->setType('UNIQUE')
55+
->setFor('Node')
56+
->addProperty('id', 'not null')
57+
->addOption('option', 'value');
58+
// todo
59+
$this->assertSame('todo', (string) $nodeConstraint);
60+
}
61+
62+
public function testIsEqualTo(): void
63+
{
64+
$nodeConstraint = (new NodeConstraint())
65+
->setName('name')
66+
->setFor('Node')
67+
->setType('UNIQUE');
68+
$otherNodeConstraint = (clone $nodeConstraint)
69+
->setName('other_index');
70+
$this->assertFalse($nodeConstraint->isEqualTo(123));
71+
$this->assertFalse($nodeConstraint->isEqualTo($otherNodeConstraint));
72+
$this->assertTrue($nodeConstraint->isEqualTo($nodeConstraint));
73+
$this->assertTrue($nodeConstraint->isEqualTo(clone $nodeConstraint));
74+
}
75+
}

tests/Type/NodeIndexTest.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Syndesi\CypherDataStructures\Tests\Type;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Syndesi\CypherDataStructures\Type\NodeIndex;
9+
10+
class NodeIndexTest extends TestCase
11+
{
12+
public function testIndexIsInitiallyEmpty(): void
13+
{
14+
$nodeIndex = new NodeIndex();
15+
$this->assertEmpty($nodeIndex->getName());
16+
$this->assertEmpty($nodeIndex->getType());
17+
$this->assertEmpty($nodeIndex->getFor());
18+
}
19+
20+
public function testName(): void
21+
{
22+
$nodeIndex = new NodeIndex();
23+
$this->assertNull($nodeIndex->getName());
24+
$nodeIndex->setName('some_name');
25+
$this->assertSame('some_name', $nodeIndex->getName());
26+
$nodeIndex->setName(null);
27+
$this->assertNull($nodeIndex->getName());
28+
}
29+
30+
public function testType(): void
31+
{
32+
$nodeIndex = new NodeIndex();
33+
$this->assertNull($nodeIndex->getType());
34+
$nodeIndex->setType('BTREE');
35+
$this->assertSame('BTREE', $nodeIndex->getType());
36+
$nodeIndex->setType(null);
37+
$this->assertNull($nodeIndex->getType());
38+
}
39+
40+
public function testFor(): void
41+
{
42+
$nodeIndex = new NodeIndex();
43+
$this->assertNull($nodeIndex->getFor());
44+
$nodeIndex->setFor('SomeNodeLabel');
45+
$this->assertSame('SomeNodeLabel', $nodeIndex->getFor());
46+
$nodeIndex->setFor(null);
47+
$this->assertNull($nodeIndex->getFor());
48+
}
49+
50+
public function testToString(): void
51+
{
52+
$nodeIndex = (new NodeIndex())
53+
->setName('name')
54+
->setType('BTREE')
55+
->setFor('Node')
56+
->addProperty('id', 'not null')
57+
->addOption('option', 'value');
58+
// todo
59+
$this->assertSame('todo', (string) $nodeIndex);
60+
}
61+
62+
public function testIsEqualTo(): void
63+
{
64+
$nodeIndex = (new NodeIndex())
65+
->setName('name')
66+
->setFor('Node')
67+
->setType('BTREE');
68+
$otherNodeIndex = (clone $nodeIndex)
69+
->setName('other_index');
70+
$this->assertFalse($nodeIndex->isEqualTo(123));
71+
$this->assertFalse($nodeIndex->isEqualTo($otherNodeIndex));
72+
$this->assertTrue($nodeIndex->isEqualTo($nodeIndex));
73+
$this->assertTrue($nodeIndex->isEqualTo(clone $nodeIndex));
74+
}
75+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Syndesi\CypherDataStructures\Tests\Type;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Syndesi\CypherDataStructures\Type\RelationConstraint;
9+
10+
class RelationConstraintTest extends TestCase
11+
{
12+
public function testIndexIsInitiallyEmpty(): void
13+
{
14+
$relationConstraint = new RelationConstraint();
15+
$this->assertEmpty($relationConstraint->getName());
16+
$this->assertEmpty($relationConstraint->getType());
17+
$this->assertEmpty($relationConstraint->getFor());
18+
}
19+
20+
public function testName(): void
21+
{
22+
$relationConstraint = new RelationConstraint();
23+
$this->assertNull($relationConstraint->getName());
24+
$relationConstraint->setName('some_name');
25+
$this->assertSame('some_name', $relationConstraint->getName());
26+
$relationConstraint->setName(null);
27+
$this->assertNull($relationConstraint->getName());
28+
}
29+
30+
public function testType(): void
31+
{
32+
$relationConstraint = new RelationConstraint();
33+
$this->assertNull($relationConstraint->getType());
34+
$relationConstraint->setType('SOME_TYPE');
35+
$this->assertSame('SOME_TYPE', $relationConstraint->getType());
36+
$relationConstraint->setType(null);
37+
$this->assertNull($relationConstraint->getType());
38+
}
39+
40+
public function testFor(): void
41+
{
42+
$relationConstraint = new RelationConstraint();
43+
$this->assertNull($relationConstraint->getFor());
44+
$relationConstraint->setFor('RELATION');
45+
$this->assertSame('RELATION', $relationConstraint->getFor());
46+
$relationConstraint->setFor(null);
47+
$this->assertNull($relationConstraint->getFor());
48+
}
49+
50+
public function testToString(): void
51+
{
52+
$relationConstraint = (new RelationConstraint())
53+
->setName('name')
54+
->setType('UNIQUE')
55+
->setFor('RELATION')
56+
->addProperty('id', 'not null')
57+
->addOption('option', 'value');
58+
// todo
59+
$this->assertSame('todo', (string) $relationConstraint);
60+
}
61+
62+
public function testIsEqualTo(): void
63+
{
64+
$relationConstraint = (new RelationConstraint())
65+
->setName('name')
66+
->setFor('RELATION')
67+
->setType('UNIQUE');
68+
$otherRelationConstraint = (clone $relationConstraint)
69+
->setName('other_index');
70+
$this->assertFalse($relationConstraint->isEqualTo(123));
71+
$this->assertFalse($relationConstraint->isEqualTo($otherRelationConstraint));
72+
$this->assertTrue($relationConstraint->isEqualTo($relationConstraint));
73+
$this->assertTrue($relationConstraint->isEqualTo(clone $relationConstraint));
74+
}
75+
}

tests/Type/RelationIndexTest.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Syndesi\CypherDataStructures\Tests\Type;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Syndesi\CypherDataStructures\Type\RelationIndex;
9+
10+
class RelationIndexTest extends TestCase
11+
{
12+
public function testIndexIsInitiallyEmpty(): void
13+
{
14+
$relationIndex = new RelationIndex();
15+
$this->assertEmpty($relationIndex->getName());
16+
$this->assertEmpty($relationIndex->getType());
17+
$this->assertEmpty($relationIndex->getFor());
18+
}
19+
20+
public function testName(): void
21+
{
22+
$relationIndex = new RelationIndex();
23+
$this->assertNull($relationIndex->getName());
24+
$relationIndex->setName('some_name');
25+
$this->assertSame('some_name', $relationIndex->getName());
26+
$relationIndex->setName(null);
27+
$this->assertNull($relationIndex->getName());
28+
}
29+
30+
public function testType(): void
31+
{
32+
$relationIndex = new RelationIndex();
33+
$this->assertNull($relationIndex->getType());
34+
$relationIndex->setType('BTREE');
35+
$this->assertSame('BTREE', $relationIndex->getType());
36+
$relationIndex->setType(null);
37+
$this->assertNull($relationIndex->getType());
38+
}
39+
40+
public function testFor(): void
41+
{
42+
$relationIndex = new RelationIndex();
43+
$this->assertNull($relationIndex->getFor());
44+
$relationIndex->setFor('SOME_RELATION_TYPE');
45+
$this->assertSame('SOME_RELATION_TYPE', $relationIndex->getFor());
46+
$relationIndex->setFor(null);
47+
$this->assertNull($relationIndex->getFor());
48+
}
49+
50+
public function testToString(): void
51+
{
52+
$relationIndex = (new RelationIndex())
53+
->setName('name')
54+
->setType('BTREE')
55+
->setFor('RELATION')
56+
->addProperty('id', 'not null')
57+
->addOption('option', 'value');
58+
// todo
59+
$this->assertSame('todo', (string) $relationIndex);
60+
}
61+
62+
public function testIsEqualTo(): void
63+
{
64+
$relationIndex = (new RelationIndex())
65+
->setName('name')
66+
->setFor('RELATION')
67+
->setType('BTREE');
68+
$otherRelationIndex = (clone $relationIndex)
69+
->setName('other_index');
70+
$this->assertFalse($relationIndex->isEqualTo(123));
71+
$this->assertFalse($relationIndex->isEqualTo($otherRelationIndex));
72+
$this->assertTrue($relationIndex->isEqualTo($relationIndex));
73+
$this->assertTrue($relationIndex->isEqualTo(clone $relationIndex));
74+
}
75+
}

0 commit comments

Comments
 (0)