Add test for cases of actors dying about 95 years ago (between Berne

convention expiry and max. expiry) and fix early variable access
This commit is contained in:
Joshua Ramon Enslin 2023-10-05 20:42:29 +02:00
parent 5d300d02bd
commit 7596d9f18e
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 75 additions and 2 deletions

View File

@ -49,12 +49,13 @@ final class MDPlausiForLegalStatus {
private function _determineExpectedStatus():string {
$currentYear = (int)date("Y");
$deathYearOfLastCreator = (int)date("Y", $this->_death_of_last_creator);
if (!isset($deathYearOfLastCreator)) {
if (!isset($this->_death_of_last_creator)) {
return 'any';
}
$deathYearOfLastCreator = (int)date("Y", $this->_death_of_last_creator);
if ($currentYear - self::YEARS_AFTER_DEATH_TO_PUBLIC_DOMAIN > $deathYearOfLastCreator) {
return 'pd';
}

View File

@ -47,6 +47,29 @@ final class MDPlausiForLegalStatusTest extends TestCase {
}
/**
* Ensures that no warning is present if no information has been provided.
*
* @return void
*/
public function testNoWarningForObjectWithActorsDeceased95YearsAgo():void {
$plausiEvent = new MDPlausiEvent(1,
"",
"",
"",
"Somebody",
date("Y", strtotime("-95 years")),
date("Y", strtotime("-95 years")));
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent], [['name' => 'test.jpg', 'license' => 'RR-F']]);
$warningStatus = $plausiLegal->evaluateSimple();
self::assertFalse($warningStatus['has_warning']);
self::assertEmpty($warningStatus['msgs']);
}
/**
* Ensures that a warning is returned, if the object's representations are published under
* restrictive licenses Checks the integration / evaluation function.
@ -105,6 +128,31 @@ final class MDPlausiForLegalStatusTest extends TestCase {
}
/**
* Ensures that a warning is returned, if the object's representations are published under
* restrictive licenses Checks the integration / evaluation function.
*
* @return void
*/
public function testPublicDomainObjectExpectsPdForActorsWithNoDeathDateBornInMedievalTimes():void {
$plausiEvent = new MDPlausiEvent(1,
"",
"",
"",
"Helmut Meyer23",
"1400",
"");
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent], [['name' => 'test23.jpg', 'license' => 'RR-F']]);
$warningStatus = $plausiLegal->evaluateSimple();
self::assertTrue($warningStatus['has_warning']);
self::assertNotEmpty($warningStatus['msgs']);
self::assertEquals(MDPlausiLegalCheckResultType::expect_public_domain, $warningStatus['msgs'][0]['type']);
}
/**
* Ensures that a warning is returned if the author / creator died only in the current year.
*
@ -129,6 +177,30 @@ final class MDPlausiForLegalStatusTest extends TestCase {
}
/**
* Ensures that a warning is returned if the author / creator died only in the current year.
*
* @return void
*/
public function testCreatorBornWithinLast100YearsAsksForRestrictedLicense():void {
$plausiEvent = new MDPlausiEvent(1,
"",
"",
"",
"Helmut Meyer",
"1922",
"");
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent], [['name' => 'test.jpg', 'license' => 'Public Domain Mark']]);
$warningStatus = $plausiLegal->evaluateSimple();
self::assertTrue($warningStatus['has_warning']);
self::assertNotEmpty($warningStatus['msgs']);
self::assertEquals(MDPlausiLegalCheckResultType::expect_restricted_legal_status, $warningStatus['msgs'][0]['type']);
}
/**
* Ensures that a warning is returned if the creator is still alive.
*