*/ declare(strict_types = 1); use PHPUnit\Framework\TestCase; require_once __DIR__ . '/../src/Checks/PlausiForLegalStatus/MDPlausiForLegalStatus.php'; require_once __DIR__ . '/../src/Checks/Puqi/MDPuqi.php'; require_once __DIR__ . '/../src/Checks/Plausi/MDEventCategory.php'; require_once __DIR__ . '/../src/Checks/Plausi/MDPlausiEvent.php'; // require_once __DIR__ . '/../../MDTlLoader/src/MDTlLoader.php'; require_once __DIR__ . '/../../importer/dependencies/MDAllowedValueSets/src/MDRequirementsSet.php'; require_once __DIR__ . '/../../importer/dependencies/MDAllowedValueSets/src/MDValueSet.php'; require_once __DIR__ . '/../../importer/dependencies/MDAllowedValueSets/src/MDEventsSet.php'; require_once __DIR__ . '/../../importer/dependencies/MDAllowedValueSets/src/enums/MDCopyrightCollective.php'; /** * Tests for PlausiForLegalStatus. */ final class MDPlausiForLegalStatusTest extends TestCase { /** * Ensures that no warning is present if no information has been provided. * * @return void */ public function testNoWarningForObjectWithNoInfo():void { $plausiEvent = new MDPlausiEvent(1, "", "", "", "", "", ""); $plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]); $warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'RR-F']]); 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. * * @return void */ public function testPublicDomainObjectExpectsPd():void { $plausiEvent = new MDPlausiEvent(1, "1899", "1899", "1899", "Helmut Meyer", "1859", "1900"); $plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]); $warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'RR-F']]); self::assertTrue($warningStatus['has_warning']); self::assertNotEmpty($warningStatus['msgs']); self::assertEquals('expect_public_domain', $warningStatus['msgs'][0]['type']); } /** * Ensures that a warning is returned if the author / creator died only in the current year. * * @return void */ public function testCurrentCreatorAsksForRestrictedLicense():void { $plausiEvent = new MDPlausiEvent(1, date("Y"), date("Y"), date("Y"), "Helmut Meyer", strval((int)date("Y") - 20), date("Y")); $plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]); $warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'Public Domain Mark']]); self::assertTrue($warningStatus['has_warning']); self::assertNotEmpty($warningStatus['msgs']); self::assertEquals('expect_restricted_legal_status', $warningStatus['msgs'][0]['type']); } /** * Ensures that a warning is returned if the creator is still alive. * * @return void */ public function testCreatorsWhoAreStillAliveAsksForRestrictedLicense():void { $plausiEvent = new MDPlausiEvent(1, date("Y"), date("Y"), date("Y"), "Helmut Meyer", strval((int)date("Y") - 20), ""); $plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]); $warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'Public Domain Mark']]); self::assertTrue($warningStatus['has_warning'], var_export($plausiLegal, true)); self::assertNotEmpty($warningStatus['msgs']); self::assertEquals('expect_restricted_legal_status', $warningStatus['msgs'][0]['type']); } /** * Ensures that a warning is returned if the creator is represented by a copyright collective. * * @return void */ public function testCreatorsInCopyrightCollectiveAsksForRestrictedLicense():void { $plausiEvent = new MDPlausiEvent(1, date("Y"), date("Y"), date("Y"), "Helmut Meyer", strval((int)date("Y") - 20), ""); $plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]); $plausiLegal->setCreatorsRepresentedByCopyrightCollective(["Helmut Meyer" => MDCopyrightCollective::vg_bildkunst]); $warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'Public Domain Mark']]); self::assertTrue($warningStatus['has_warning']); self::assertNotEmpty($warningStatus['msgs']); self::assertEquals('expect_restricted_legal_status', $warningStatus['msgs'][0]['type']); self::assertArrayHasKey('additional', $warningStatus['msgs'][0]); self::assertEquals(MDCopyrightCollective::vg_bildkunst, $warningStatus['msgs'][0]['additional']['representation']); } }