diff --git a/src/Dto/Dependency.php b/src/Dto/Dependency.php deleted file mode 100644 index 840b73539..000000000 --- a/src/Dto/Dependency.php +++ /dev/null @@ -1,69 +0,0 @@ -dependency->getSourceId(); - } - - public function getRequires(int $offset = null, int $limit = null): array - { - return $this->dependency->getRequires($offset, $limit); - } - - public function getFilterRequiresByPath(int $offset = null, int $limit = null, string $value = null): array - { - return $this->dependency->getFilterRequiresByPath($offset, $limit, $value); - } - - public function getFilterRequiredByPath(int $offset = null, int $limit = null, string $value = null): array - { - return $this->dependency->getFilterRequiredByPath($offset, $limit, $value); - } - - public function getRequiredBy(int $offset = null, int $limit = null): array - { - return $this->dependency->getRequiredBy($offset, $limit); - } - - public function getSourceType(): string - { - return $this->dependency->getSourceType(); - } - - public function getRequiresTotalCount(): int - { - return $this->dependency->getRequiresTotalCount(); - } - - public function getRequiredByTotalCount(): int - { - return $this->dependency->getRequiredByTotalCount(); - } - - public function isRequired(): bool - { - return $this->dependency->isRequired(); - } -} diff --git a/tests/Unit/Dependency/DependencyHydratorTest.php b/tests/Unit/Dependency/DependencyHydratorTest.php new file mode 100644 index 000000000..da219f254 --- /dev/null +++ b/tests/Unit/Dependency/DependencyHydratorTest.php @@ -0,0 +1,77 @@ +getHydrator(); + + $dependency = $hydrator->hydrate(['id' => 1, 'type' => 'document']); + + $this->assertSame(1, $dependency->getId()); + $this->assertSame('/testtest', $dependency->getPath()); + $this->assertSame('document', $dependency->getType()); + $this->assertSame('page', $dependency->getSubType()); + $this->assertTrue($dependency->isPublished()); + $this->assertEmpty($dependency->getAdditionalAttributes()); + } + + + /** + * @throws Exception + */ + private function getHydrator(): DependencyHydratorInterface + { + return new DependencyHydrator($this->mockServiceResolver()); + } + + /** + * @throws Exception + */ + private function mockServiceResolver(): ServiceResolverInterface + { + return $this->makeEmpty(ServiceResolverInterface::class, + [ + 'getElementById' => $this->getDocument(), + 'getElementType' => 'document', + 'isPublished' => true, + ]); + } + + private function getDocument(): Document + { + $document = new Document(); + $document->setPath('/test'); + $document->setId(1); + $document->setType('page'); + $document->setKey('test'); + + return $document; + } +}