Skip to content

Commit

Permalink
MetaData: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schmitz-ilias committed Nov 15, 2024
1 parent db9bdab commit 422c744
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class CopyrightHandler implements CopyrightHandlerInterface
{
protected CopyrightRepository $copyright_repository;
protected IdentifierHandler $identifier_handler;
protected CopyrightRenderer $copyright_renderer;
protected SettingsInterface $settings;

/**
Expand All @@ -41,12 +40,10 @@ class CopyrightHandler implements CopyrightHandlerInterface
public function __construct(
CopyrightRepository $copyright_repository,
IdentifierHandler $identifier_handler,
CopyrightRenderer $copyright_renderer,
SettingsInterface $settings
) {
$this->copyright_repository = $copyright_repository;
$this->identifier_handler = $identifier_handler;
$this->copyright_renderer = $copyright_renderer;
$this->settings = $settings;
}

Expand Down
3 changes: 0 additions & 3 deletions components/ILIAS/MetaData/classes/XML/Services/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function standardWriter(): WriterInterface
new CopyrightHandler(
$this->copyright_services->repository(),
$this->copyright_services->identifiersHandler(),
$this->copyright_services->renderer(),
\ilMDSettings::_getInstance()
),
$this->path_services->pathFactory(),
Expand All @@ -106,7 +105,6 @@ public function standardReader(): ReaderInterface
$copyright_handler = new CopyrightHandler(
$this->copyright_services->repository(),
$this->copyright_services->identifiersHandler(),
$this->copyright_services->renderer(),
\ilMDSettings::_getInstance()
);
return $this->standard_reader = new StandardReader(
Expand Down Expand Up @@ -144,7 +142,6 @@ public function simpleDCWriter(): SimpleDCInterface
new CopyrightHandler(
$this->copyright_services->repository(),
$this->copyright_services->identifiersHandler(),
$this->copyright_services->renderer(),
\ilMDSettings::_getInstance()
),
new LinkGenerator(
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/MetaData/docs/oaipmh.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,4 @@ are derived as follows:
| source | `resource > identifier > entry` of `relation` where `kind > value` is 'isbasedon' | any | |
| relation | `resource > identifier > entry` of `relation` where `kind > value` is not 'isbasedon' | any | |
| coverage | `general > coverage > string` | any | with corresponding `general > coverage > language` as `xml:lang` attribute |
| rights | `rights > description > string` | 1 | If a [pre-configured license](copyrights.md) is chosen for the Object, it is given by its link. If no copyright is set, the default copyright is used. |
| rights | `rights > description > string` | 1 | If a [pre-configured license](copyrights.md) is chosen for the Object, it is given by its link (or its full name, if it does not have a link). If no copyright is set, the default copyright is used. |
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,6 @@ public function buildIdentifierFromEntryID(int $entry_id): string
};
}

protected function getRenderer(): RendererInterface
{
return new class () extends NullRenderer {
public function toString(CopyrightDataInterface $copyright): string
{
return 'rendered full name: "' . $copyright->fullName() . '" and link: "' . $copyright->link() . '"';
}
};
}

protected function getSettings(bool $selection_active): SettingsInterface
{
return new class ($selection_active) extends NullSettings {
Expand All @@ -177,7 +167,6 @@ public function testIsCopyrightSelectionActiveTrue(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -189,7 +178,6 @@ public function testIsCopyrightSelectionActiveFalse(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(false)
);

Expand All @@ -206,12 +194,11 @@ public function testCopyrightAsString(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

$this->assertSame(
'rendered full name: "second entry" and link: "http://www.example2.com"',
'http://www.example2.com',
$handler->copyrightAsString('valid_identifier_55')
);
}
Expand All @@ -226,7 +213,6 @@ public function testCopyrightAsStringInactiveCPSelection(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(false)
);

Expand All @@ -246,7 +232,6 @@ public function testCopyrightAsStringInvalidAsIdentifier(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -266,12 +251,11 @@ public function testCopyrightAsStringEntryIdNotFound(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

$this->assertSame(
'rendered full name: "" and link: ""',
'',
$handler->copyrightAsString('valid_identifier_678')
);
}
Expand All @@ -286,7 +270,6 @@ public function testCopyrightForExportInvalidAsIdentifier(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -306,7 +289,6 @@ public function testCopyrightForExportEntryIdNotFound(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -326,7 +308,6 @@ public function testCopyrightForExportInactiveCPSelection(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(false)
);

Expand All @@ -346,7 +327,6 @@ public function testCopyrightForExportEmpty(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -366,7 +346,6 @@ public function testCopyrightForExportHasLink(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -386,7 +365,6 @@ public function testCopyrightForExportHasFullName(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -406,7 +384,6 @@ public function testCopyrightForExportHasFullNameAndLink(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -426,7 +403,6 @@ public function testCopyrightForExportHasNoFullNameOrLink(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -446,7 +422,6 @@ public function testCopyrightFromExportNoMatches(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -466,7 +441,6 @@ public function testCopyrightFromExportURLWithNoMatchesShouldBeUnchanged(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -490,7 +464,6 @@ public function testCopyrightFromExportNoMatchesContainsFullName(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -510,7 +483,6 @@ public function testCopyrightFromExportInactiveCPSelection(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(false)
);

Expand All @@ -530,7 +502,6 @@ public function testCopyrightFromExportMatchesByFullName(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -554,7 +525,6 @@ public function testCopyrightFromExportMultipleMatchesByFullName(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -574,7 +544,6 @@ public function testCopyrightFromExportMatchesByLink(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -594,7 +563,6 @@ public function testCopyrightFromExportMultipleMatchesByLink(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand All @@ -614,7 +582,6 @@ public function testCopyrightFromExportMatchesByLinkButDifferentScheme(): void
$handler = new CopyrightHandler(
$this->getCopyrightRepository(...$entries),
$this->getIdentifierHandler(),
$this->getRenderer(),
$this->getSettings(true)
);

Expand Down

0 comments on commit 422c744

Please sign in to comment.