|
| 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 | +} |
0 commit comments