Cerys 3 weeks ago
parent
commit
a12b6cd524
  1. 26
      src/QueryBuilder/LinkQuery/LinkQueryBuilder.php
  2. 18
      tests/QueryBuilderLinkTest.php

26
src/QueryBuilder/LinkQuery/LinkQueryBuilder.php

@ -31,25 +31,27 @@ class LinkQueryBuilder
public function LinkWhat(string $relativePath): LinkQueryBuilder public function LinkToRelativePath(string $relativePath1, string $relativePath2): LinkQueryBuilder
{
self::ValidateDeegraphPath(target: $relativePath);
$this->RelativePath1 = $relativePath;
return $this;
}
public function LinkTo(string $relativePath): LinkQueryBuilder
{ {
self::EnsureNotSet($this->RelativePath1);
self::EnsureNotSet($this->RelativePath2); self::EnsureNotSet($this->RelativePath2);
self::ValidateDeegraphPath(target: $relativePath); self::ValidateDeegraphPath(target: $relativePath1);
$this->RelativePath2 = $relativePath; self::ValidateDeegraphPath(target: $relativePath2);
$this->RelativePath1 = $relativePath1;
$this->RelativePath2 = $relativePath2;
$this->ToOrOf = "TO"; $this->ToOrOf = "TO";
return $this; return $this;
} }
public function LinkOf(string $relativePath): LinkQueryBuilder public function LinkOfRelativePath(string $relativePath1, string $relativePath2): LinkQueryBuilder
{ {
self::EnsureNotSet($this->RelativePath1);
self::EnsureNotSet($this->RelativePath2); self::EnsureNotSet($this->RelativePath2);
self::ValidateDeegraphPath(target: $relativePath); self::ValidateDeegraphPath(target: $relativePath1);
$this->RelativePath2 = $relativePath; self::ValidateDeegraphPath(target: $relativePath2);
$this->RelativePath1 = $relativePath1;
$this->RelativePath2 = $relativePath2;
$this->ToOrOf = "OF"; $this->ToOrOf = "OF";
return $this; return $this;
} }

18
tests/QueryBuilderLinkTest.php

@ -14,8 +14,7 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test", expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkWhat($this->TestUUID) ->LinkToRelativePath($this->TestUUID, $this->TestUUID)
->LinkTo($this->TestUUID)
->As("test") ->As("test")
->Build() ->Build()
); );
@ -25,8 +24,7 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test OVERWRITE", expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test OVERWRITE",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkWhat($this->TestUUID) ->LinkToRelativePath($this->TestUUID, $this->TestUUID)
->LinkTo($this->TestUUID)
->As("test") ->As("test")
->Overwrite() ->Overwrite()
->Build() ->Build()
@ -37,8 +35,7 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test REPLACE", expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test REPLACE",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkWhat($this->TestUUID) ->LinkToRelativePath($this->TestUUID, $this->TestUUID)
->LinkTo($this->TestUUID)
->As("test") ->As("test")
->Replace() ->Replace()
->Build() ->Build()
@ -49,8 +46,7 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test FORCE", expected: "LINK {$this->TestUUID} TO {$this->TestUUID} AS test FORCE",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkWhat($this->TestUUID) ->LinkToRelativePath($this->TestUUID, $this->TestUUID)
->LinkTo($this->TestUUID)
->As("test") ->As("test")
->Force() ->Force()
->Build() ->Build()
@ -61,8 +57,7 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} OF {$this->TestUUID} AS test", expected: "LINK {$this->TestUUID} OF {$this->TestUUID} AS test",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkWhat($this->TestUUID) ->LinkOfRelativePath($this->TestUUID, $this->TestUUID)
->LinkOf($this->TestUUID)
->As("test") ->As("test")
->Build() ->Build()
); );
@ -73,8 +68,7 @@ final class QueryBuilderLinkTest extends TestCase
self::assertEquals( self::assertEquals(
expected: "LINK {$this->TestUUID} OF {$this->TestUUID} AS test", expected: "LINK {$this->TestUUID} OF {$this->TestUUID} AS test",
actual: QueryBuilder::Link() actual: QueryBuilder::Link()
->LinkWhat($this->TestUUID) ->LinkOfRelativePath($this->TestUUID, $this->TestUUID)
->LinkOf($this->TestUUID)
->As("test") ->As("test")
->Overwrite() ->Overwrite()
->Replace() ->Replace()

Loading…
Cancel
Save