Restructure MDPlausiForLegalStatus to take image rights from the
constructor on, add translations Close #2
This commit is contained in:
parent
4454217cc0
commit
0d9feaed19
|
@ -25,6 +25,8 @@ final class MDPlausiForLegalStatus {
|
||||||
|
|
||||||
/** @var array<MDPlausiEvent> */
|
/** @var array<MDPlausiEvent> */
|
||||||
private array $_events;
|
private array $_events;
|
||||||
|
/** @var array<array{name: string, license: string}> */
|
||||||
|
private array $_representations;
|
||||||
|
|
||||||
# private string $_latest_production_name;
|
# private string $_latest_production_name;
|
||||||
private int $_latest_production;
|
private int $_latest_production;
|
||||||
|
@ -90,7 +92,9 @@ final class MDPlausiForLegalStatus {
|
||||||
# $this->_production->latest_time_name = $event->actor_death;
|
# $this->_production->latest_time_name = $event->actor_death;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actors who have not yet died
|
// Actors who have not yet died will have their birth set as the last
|
||||||
|
// possible time. This is a bit hacky, but should work for all
|
||||||
|
// actors who have not lived beyond 100 years.
|
||||||
if (
|
if (
|
||||||
$event->actor_death_normalized === false
|
$event->actor_death_normalized === false
|
||||||
&& $event->actor_birth_normalized !== false
|
&& $event->actor_birth_normalized !== false
|
||||||
|
@ -111,11 +115,9 @@ final class MDPlausiForLegalStatus {
|
||||||
* Evaluates a range of representations and returns a simple answer without translations.
|
* Evaluates a range of representations and returns a simple answer without translations.
|
||||||
* For translations, use the wrapper function $this->evaluate().
|
* For translations, use the wrapper function $this->evaluate().
|
||||||
*
|
*
|
||||||
* @param array<array{name: string, license: string}> $representations Representations of the object.
|
* @return array{has_warning: bool, msgs: array<array{name: string, license: string, reason: MDPlausiLegalCheckReason, type: MDPlausiLegalCheckResultType, additional?: array{representation: MDCopyrightCollective}}>}
|
||||||
*
|
|
||||||
* @return array{has_warning: bool, msgs: array<array{name: string, license: string, type: string, additional?: array{representation: MDCopyrightCollective}}>}
|
|
||||||
*/
|
*/
|
||||||
public function evaluateSimple(array $representations):array {
|
public function evaluateSimple():array {
|
||||||
|
|
||||||
if ($this->_expected_status === 'any') {
|
if ($this->_expected_status === 'any') {
|
||||||
return ['has_warning' => false, 'msgs' => []];
|
return ['has_warning' => false, 'msgs' => []];
|
||||||
|
@ -126,7 +128,7 @@ final class MDPlausiForLegalStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
$msgs = [];
|
$msgs = [];
|
||||||
foreach ($representations as $representation) {
|
foreach ($this->_representations as $representation) {
|
||||||
|
|
||||||
|
|
||||||
if ($this->_expected_status === 'pd'
|
if ($this->_expected_status === 'pd'
|
||||||
|
@ -135,7 +137,8 @@ final class MDPlausiForLegalStatus {
|
||||||
$msgs[] = [
|
$msgs[] = [
|
||||||
'name' => $representation['name'],
|
'name' => $representation['name'],
|
||||||
'license' => $representation['license'],
|
'license' => $representation['license'],
|
||||||
'type' => 'expect_public_domain',
|
'reason' => MDPlausiLegalCheckReason::creator_dead_for_years,
|
||||||
|
'type' => MDPlausiLegalCheckResultType::expect_public_domain,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +150,8 @@ final class MDPlausiForLegalStatus {
|
||||||
$msgs[] = [
|
$msgs[] = [
|
||||||
'name' => $representation['name'],
|
'name' => $representation['name'],
|
||||||
'license' => $representation['license'],
|
'license' => $representation['license'],
|
||||||
'type' => 'expect_restricted_legal_status',
|
'reason' => MDPlausiLegalCheckReason::creator_recently_or_not_dead,
|
||||||
|
'type' => MDPlausiLegalCheckResultType::expect_restricted_legal_status,
|
||||||
'additional' => [
|
'additional' => [
|
||||||
'representation' => $collective
|
'representation' => $collective
|
||||||
],
|
],
|
||||||
|
@ -157,7 +161,8 @@ final class MDPlausiForLegalStatus {
|
||||||
$msgs[] = [
|
$msgs[] = [
|
||||||
'name' => $representation['name'],
|
'name' => $representation['name'],
|
||||||
'license' => $representation['license'],
|
'license' => $representation['license'],
|
||||||
'type' => 'expect_restricted_legal_status',
|
'reason' => MDPlausiLegalCheckReason::creator_recently_or_not_dead,
|
||||||
|
'type' => MDPlausiLegalCheckResultType::expect_restricted_legal_status,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,18 +175,39 @@ final class MDPlausiForLegalStatus {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formulates a human-readable, translated text message for a notice.
|
||||||
|
*
|
||||||
|
* @param MDTlLoader $tlLoader Translation loader.
|
||||||
|
* @param array{name: string, license: string, reason: MDPlausiLegalCheckReason, type: MDPlausiLegalCheckResultType, additional?: array{representation: MDCopyrightCollective}} $msg Input message.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function _formulateText(MDTlLoader $tlLoader, array $msg):string {
|
||||||
|
|
||||||
|
$output = $tlLoader->tl("basis", "basis", "image") . ' "' . $msg['name'] . '": ' . $msg['reason']->getTl($tlLoader) . ' ' . $msg['type']->getTl($tlLoader);
|
||||||
|
|
||||||
|
$output .= ' ' . $tlLoader->tl("quality", "quality", "current_license") . ': ' . $msg['license'] . '.';
|
||||||
|
|
||||||
|
if (!empty($msg['additional'])) {
|
||||||
|
$output .= ' ' . $tlLoader->tl("quality", "quality", "creator_represented_by_copyright_collective") . ': ' . $msg['additional']['representation']->getName() . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates an object's representations' legal / licensing status based on
|
* Evaluates an object's representations' legal / licensing status based on
|
||||||
* the expected values.
|
* the expected values.
|
||||||
*
|
*
|
||||||
* @param MDTlLoader $tlLoader Translation loader.
|
* @param MDTlLoader $tlLoader Translation loader.
|
||||||
* @param array<array{name: string, license: string}> $representations Representations of the object.
|
|
||||||
*
|
*
|
||||||
* @return array{has_warning: bool, msgs: array<array{name: string, license: string, type: string, text: string}>}
|
* @return array{has_warning: bool, msgs: array<array{name: string, license: string, reason: MDPlausiLegalCheckReason, type: MDPlausiLegalCheckResultType, text: string, link: string}>}
|
||||||
*/
|
*/
|
||||||
public function evaluate(MDTlLoader $tlLoader, array $representations):array {
|
public function evaluate(MDTlLoader $tlLoader):array {
|
||||||
|
|
||||||
$evaluation = $this->evaluateSimple($representations);
|
$evaluation = $this->evaluateSimple();
|
||||||
if ($evaluation['has_warning'] === false) {
|
if ($evaluation['has_warning'] === false) {
|
||||||
return ['has_warning' => false, 'msgs' => []];
|
return ['has_warning' => false, 'msgs' => []];
|
||||||
}
|
}
|
||||||
|
@ -189,11 +215,18 @@ final class MDPlausiForLegalStatus {
|
||||||
$output = [];
|
$output = [];
|
||||||
foreach ($evaluation['msgs'] as $msg) {
|
foreach ($evaluation['msgs'] as $msg) {
|
||||||
|
|
||||||
throw new Exception("To be implemented");
|
if (!empty($msg['additional'])) {
|
||||||
|
$link = $msg['additional']['representation']->getContactForm();
|
||||||
|
}
|
||||||
|
else $link = '';
|
||||||
|
|
||||||
$output[] = [
|
$output[] = [
|
||||||
'name' => $msg['name'],
|
'name' => $msg['name'],
|
||||||
'license' => $msg['license'],
|
'license' => $msg['license'],
|
||||||
|
'reason' => $msg['reason'],
|
||||||
'type' => $msg['type'],
|
'type' => $msg['type'],
|
||||||
|
'text' => $this->_formulateText($tlLoader, $msg),
|
||||||
|
'link' => $link,
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -222,12 +255,14 @@ final class MDPlausiForLegalStatus {
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param array<MDPlausiEvent> $events Events.
|
* @param array<MDPlausiEvent> $events Events.
|
||||||
|
* @param array<array{name: string, license: string}> $representations Representations of the object.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(array $events) {
|
public function __construct(array $events, array $representations) {
|
||||||
|
|
||||||
$this->_events = $events;
|
$this->_events = $events;
|
||||||
|
$this->_representations = $representations;
|
||||||
|
|
||||||
$this->_categorizeEvents();
|
$this->_categorizeEvents();
|
||||||
$this->_expected_status = $this->_determineExpectedStatus();
|
$this->_expected_status = $this->_determineExpectedStatus();
|
||||||
|
|
119
src/Checks/PlausiForLegalStatus/MDPlausiLegalCheckReason.php
Normal file
119
src/Checks/PlausiForLegalStatus/MDPlausiLegalCheckReason.php
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
<?PHP
|
||||||
|
/**
|
||||||
|
* Describes a reason for a notice on why the provided copyright status of
|
||||||
|
* an object or its representations is invalid.
|
||||||
|
*
|
||||||
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a possible status for to-dos.
|
||||||
|
*/
|
||||||
|
enum MDPlausiLegalCheckReason implements JsonSerializable {
|
||||||
|
|
||||||
|
case creator_dead_for_years;
|
||||||
|
case creator_recently_or_not_dead;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a value of this type based on a string.
|
||||||
|
*
|
||||||
|
* @param string $input Input to get a value from.
|
||||||
|
*
|
||||||
|
* @return MDPlausiLegalCheckReason
|
||||||
|
*/
|
||||||
|
public static function fromString(string $input):MDPlausiLegalCheckReason {
|
||||||
|
|
||||||
|
return match($input) {
|
||||||
|
'creator_dead_for_years' => self::creator_dead_for_years,
|
||||||
|
'creator_recently_or_not_dead' => self::creator_recently_or_not_dead,
|
||||||
|
default => throw new MDpageParameterNotFromListException("Unknown reason"),
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a value of this type based on a integer.
|
||||||
|
*
|
||||||
|
* @param integer $input Input to get a value from.
|
||||||
|
*
|
||||||
|
* @return MDPlausiLegalCheckReason
|
||||||
|
*/
|
||||||
|
public static function fromInt(int $input):MDPlausiLegalCheckReason {
|
||||||
|
|
||||||
|
return match($input) {
|
||||||
|
1 => self::creator_dead_for_years,
|
||||||
|
2 => self::creator_recently_or_not_dead,
|
||||||
|
default => throw new MDpageParameterNotFromListException("Unknown reason"),
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a numeric representation of the type, e.g. for efficient storage in a DB.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function toInt():int {
|
||||||
|
|
||||||
|
return match($this) {
|
||||||
|
self::creator_dead_for_years => 1,
|
||||||
|
self::creator_recently_or_not_dead => 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all available names.
|
||||||
|
*
|
||||||
|
* @return array<string>
|
||||||
|
*/
|
||||||
|
public static function caseNames():array {
|
||||||
|
|
||||||
|
$output = [];
|
||||||
|
|
||||||
|
$cases = self::cases();
|
||||||
|
foreach ($cases as $case) {
|
||||||
|
$output[] = $case->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a translation for the entry.
|
||||||
|
*
|
||||||
|
* @param MDTlLoader $tlLoader Translation loader.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTl(MDTlLoader $tlLoader):string {
|
||||||
|
|
||||||
|
$tl = $tlLoader->tl("quality", "quality", "legal_check_reason_" . $this->name);
|
||||||
|
|
||||||
|
$toReplaceWith = (string)match($this) {
|
||||||
|
self::creator_dead_for_years => MDPlausiForLegalStatus::YEARS_AFTER_DEATH_TO_PUBLIC_DOMAIN,
|
||||||
|
self::creator_recently_or_not_dead => MDPlausiForLegalStatus::YEARS_AFTER_DEATH_TO_PUBLIC_DOMAIN_CERTAIN,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (str_contains($tl, "[placeholder_copyright_expiry]") === false) {
|
||||||
|
throw new Exception("Error in translating. Language " . $tlLoader->getLang() . " is missing placeholder [placeholder_copyright_expiry].");
|
||||||
|
}
|
||||||
|
|
||||||
|
return str_replace("[placeholder_copyright_expiry]", $toReplaceWith, $tl);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the option to serialize as a string during json_encode().
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function jsonSerialize():string {
|
||||||
|
|
||||||
|
return $this->name;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
108
src/Checks/PlausiForLegalStatus/MDPlausiLegalCheckResultType.php
Normal file
108
src/Checks/PlausiForLegalStatus/MDPlausiLegalCheckResultType.php
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?PHP
|
||||||
|
/**
|
||||||
|
* Describes a suggestion / warning for possible invalid legal statuses of an object's
|
||||||
|
* or its representations legal status.
|
||||||
|
*
|
||||||
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a possible status for to-dos.
|
||||||
|
*/
|
||||||
|
enum MDPlausiLegalCheckResultType implements JsonSerializable {
|
||||||
|
|
||||||
|
case expect_public_domain;
|
||||||
|
case expect_restricted_legal_status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a value of this type based on a string.
|
||||||
|
*
|
||||||
|
* @param string $input Input to get a value from.
|
||||||
|
*
|
||||||
|
* @return MDPlausiLegalCheckResultType
|
||||||
|
*/
|
||||||
|
public static function fromString(string $input):MDPlausiLegalCheckResultType {
|
||||||
|
|
||||||
|
return match($input) {
|
||||||
|
'expect_public_domain' => self::expect_public_domain,
|
||||||
|
'expect_restricted_legal_status' => self::expect_restricted_legal_status,
|
||||||
|
default => throw new MDpageParameterNotFromListException("Unknown result type"),
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a value of this type based on a integer.
|
||||||
|
*
|
||||||
|
* @param integer $input Input to get a value from.
|
||||||
|
*
|
||||||
|
* @return MDPlausiLegalCheckResultType
|
||||||
|
*/
|
||||||
|
public static function fromInt(int $input):MDPlausiLegalCheckResultType {
|
||||||
|
|
||||||
|
return match($input) {
|
||||||
|
1 => self::expect_public_domain,
|
||||||
|
2 => self::expect_restricted_legal_status,
|
||||||
|
default => throw new MDpageParameterNotFromListException("Unknown result type"),
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a numeric representation of the type, e.g. for efficient storage in a DB.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function toInt():int {
|
||||||
|
|
||||||
|
return match($this) {
|
||||||
|
self::expect_public_domain => 1,
|
||||||
|
self::expect_restricted_legal_status => 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all available names.
|
||||||
|
*
|
||||||
|
* @return array<string>
|
||||||
|
*/
|
||||||
|
public static function caseNames():array {
|
||||||
|
|
||||||
|
$output = [];
|
||||||
|
|
||||||
|
$cases = self::cases();
|
||||||
|
foreach ($cases as $case) {
|
||||||
|
$output[] = $case->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a translation for the entry.
|
||||||
|
*
|
||||||
|
* @param MDTlLoader $tlLoader Translation loader.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTl(MDTlLoader $tlLoader):string {
|
||||||
|
|
||||||
|
return $tlLoader->tl("quality", "quality", "legal_check_msg_type_" . $this->name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the option to serialize as a string during json_encode().
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function jsonSerialize():string {
|
||||||
|
|
||||||
|
return $this->name;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,8 @@ declare(strict_types = 1);
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
require_once __DIR__ . '/../src/Checks/PlausiForLegalStatus/MDPlausiForLegalStatus.php';
|
require_once __DIR__ . '/../src/Checks/PlausiForLegalStatus/MDPlausiForLegalStatus.php';
|
||||||
|
require_once __DIR__ . '/../src/Checks/PlausiForLegalStatus/MDPlausiLegalCheckResultType.php';
|
||||||
|
require_once __DIR__ . '/../src/Checks/PlausiForLegalStatus/MDPlausiLegalCheckReason.php';
|
||||||
require_once __DIR__ . '/../src/Checks/Puqi/MDPuqi.php';
|
require_once __DIR__ . '/../src/Checks/Puqi/MDPuqi.php';
|
||||||
require_once __DIR__ . '/../src/Checks/Plausi/MDEventCategory.php';
|
require_once __DIR__ . '/../src/Checks/Plausi/MDEventCategory.php';
|
||||||
require_once __DIR__ . '/../src/Checks/Plausi/MDPlausiEvent.php';
|
require_once __DIR__ . '/../src/Checks/Plausi/MDPlausiEvent.php';
|
||||||
|
@ -37,8 +39,8 @@ final class MDPlausiForLegalStatusTest extends TestCase {
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
|
|
||||||
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]);
|
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent], [['name' => 'test.jpg', 'license' => 'RR-F']]);
|
||||||
$warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'RR-F']]);
|
$warningStatus = $plausiLegal->evaluateSimple();
|
||||||
|
|
||||||
self::assertFalse($warningStatus['has_warning']);
|
self::assertFalse($warningStatus['has_warning']);
|
||||||
self::assertEmpty($warningStatus['msgs']);
|
self::assertEmpty($warningStatus['msgs']);
|
||||||
|
@ -61,12 +63,12 @@ final class MDPlausiForLegalStatusTest extends TestCase {
|
||||||
"1859",
|
"1859",
|
||||||
"1900");
|
"1900");
|
||||||
|
|
||||||
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]);
|
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent], [['name' => 'test.jpg', 'license' => 'RR-F']]);
|
||||||
$warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'RR-F']]);
|
$warningStatus = $plausiLegal->evaluateSimple();
|
||||||
|
|
||||||
self::assertTrue($warningStatus['has_warning']);
|
self::assertTrue($warningStatus['has_warning']);
|
||||||
self::assertNotEmpty($warningStatus['msgs']);
|
self::assertNotEmpty($warningStatus['msgs']);
|
||||||
self::assertEquals('expect_public_domain', $warningStatus['msgs'][0]['type']);
|
self::assertEquals(MDPlausiLegalCheckResultType::expect_public_domain, $warningStatus['msgs'][0]['type']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +87,12 @@ final class MDPlausiForLegalStatusTest extends TestCase {
|
||||||
strval((int)date("Y") - 20),
|
strval((int)date("Y") - 20),
|
||||||
date("Y"));
|
date("Y"));
|
||||||
|
|
||||||
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]);
|
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent], [['name' => 'test.jpg', 'license' => 'Public Domain Mark']]);
|
||||||
$warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'Public Domain Mark']]);
|
$warningStatus = $plausiLegal->evaluateSimple();
|
||||||
|
|
||||||
self::assertTrue($warningStatus['has_warning']);
|
self::assertTrue($warningStatus['has_warning']);
|
||||||
self::assertNotEmpty($warningStatus['msgs']);
|
self::assertNotEmpty($warningStatus['msgs']);
|
||||||
self::assertEquals('expect_restricted_legal_status', $warningStatus['msgs'][0]['type']);
|
self::assertEquals(MDPlausiLegalCheckResultType::expect_restricted_legal_status, $warningStatus['msgs'][0]['type']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,12 +111,12 @@ final class MDPlausiForLegalStatusTest extends TestCase {
|
||||||
strval((int)date("Y") - 20),
|
strval((int)date("Y") - 20),
|
||||||
"");
|
"");
|
||||||
|
|
||||||
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]);
|
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent], [['name' => 'test.jpg', 'license' => 'Public Domain Mark']]);
|
||||||
$warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'Public Domain Mark']]);
|
$warningStatus = $plausiLegal->evaluateSimple();
|
||||||
|
|
||||||
self::assertTrue($warningStatus['has_warning'], var_export($plausiLegal, true));
|
self::assertTrue($warningStatus['has_warning'], var_export($plausiLegal, true));
|
||||||
self::assertNotEmpty($warningStatus['msgs']);
|
self::assertNotEmpty($warningStatus['msgs']);
|
||||||
self::assertEquals('expect_restricted_legal_status', $warningStatus['msgs'][0]['type']);
|
self::assertEquals(MDPlausiLegalCheckResultType::expect_restricted_legal_status, $warningStatus['msgs'][0]['type']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,14 +135,14 @@ final class MDPlausiForLegalStatusTest extends TestCase {
|
||||||
strval((int)date("Y") - 20),
|
strval((int)date("Y") - 20),
|
||||||
"");
|
"");
|
||||||
|
|
||||||
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent]);
|
$plausiLegal = new MDPlausiForLegalStatus([$plausiEvent], [['name' => 'test.jpg', 'license' => 'Public Domain Mark']]);
|
||||||
$plausiLegal->setCreatorsRepresentedByCopyrightCollective(["Helmut Meyer" => MDCopyrightCollective::vg_bildkunst]);
|
$plausiLegal->setCreatorsRepresentedByCopyrightCollective(["Helmut Meyer" => MDCopyrightCollective::vg_bildkunst]);
|
||||||
|
|
||||||
$warningStatus = $plausiLegal->evaluateSimple([['name' => 'test.jpg', 'license' => 'Public Domain Mark']]);
|
$warningStatus = $plausiLegal->evaluateSimple();
|
||||||
|
|
||||||
self::assertTrue($warningStatus['has_warning']);
|
self::assertTrue($warningStatus['has_warning']);
|
||||||
self::assertNotEmpty($warningStatus['msgs']);
|
self::assertNotEmpty($warningStatus['msgs']);
|
||||||
self::assertEquals('expect_restricted_legal_status', $warningStatus['msgs'][0]['type']);
|
self::assertEquals(MDPlausiLegalCheckResultType::expect_restricted_legal_status, $warningStatus['msgs'][0]['type']);
|
||||||
|
|
||||||
self::assertArrayHasKey('additional', $warningStatus['msgs'][0]);
|
self::assertArrayHasKey('additional', $warningStatus['msgs'][0]);
|
||||||
self::assertEquals(MDCopyrightCollective::vg_bildkunst, $warningStatus['msgs'][0]['additional']['representation']);
|
self::assertEquals(MDCopyrightCollective::vg_bildkunst, $warningStatus['msgs'][0]['additional']['representation']);
|
||||||
|
|
|
@ -12,11 +12,17 @@ require_once __DIR__ . '/../src/Checks/Plausi/MDPlausi.php';
|
||||||
require_once __DIR__ . '/../src/Checks/Plausi/MDEventCategory.php';
|
require_once __DIR__ . '/../src/Checks/Plausi/MDEventCategory.php';
|
||||||
require_once __DIR__ . '/../src/Checks/Plausi/MDPlausiEventCategory.php';
|
require_once __DIR__ . '/../src/Checks/Plausi/MDPlausiEventCategory.php';
|
||||||
require_once __DIR__ . '/../src/Checks/Plausi/MDPlausiEvent.php';
|
require_once __DIR__ . '/../src/Checks/Plausi/MDPlausiEvent.php';
|
||||||
require_once __DIR__ . '/../../MDTlLoader/src/MDTlLoader.php';
|
# require_once __DIR__ . '/../../MDTlLoader/src/MDTlLoader.php';
|
||||||
require_once __DIR__ . '/../../importer/dependencies/MDAllowedValueSets/src/MDRequirementsSet.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/MDValueSet.php';
|
||||||
require_once __DIR__ . '/../../importer/dependencies/MDAllowedValueSets/src/MDEventsSet.php';
|
require_once __DIR__ . '/../../importer/dependencies/MDAllowedValueSets/src/MDEventsSet.php';
|
||||||
|
|
||||||
|
/** For mocking */
|
||||||
|
class MDTlLoader {
|
||||||
|
public function tl() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for plausi.
|
* Tests for plausi.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user