2022-05-17 23:27:40 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* This script contains tests for the validation of single field contents.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This script contains tests for the validation of single field contents.
|
|
|
|
*/
|
|
|
|
final class NodaValidationHelperTest extends TestCase {
|
|
|
|
/**
|
|
|
|
* Test successfully refusing too short actor descriptions.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @small
|
|
|
|
*
|
2022-05-17 23:27:40 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testActorDescriptionValidationFailsOnTooShortInput():void {
|
|
|
|
|
|
|
|
$this->expectException(MDgenericInvalidInputsException::class);
|
|
|
|
NodaValidationHelper::validateActorDescription("abc");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test successfully refusing actor descriptions that have too few distinct characters.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @small
|
|
|
|
*
|
2022-05-17 23:27:40 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testActorDescriptionValidationFailsOnTooFewDistinctCharacters():void {
|
|
|
|
|
|
|
|
$this->expectException(MDgenericInvalidInputsException::class);
|
|
|
|
NodaValidationHelper::validateActorDescription("aaaaaaaaaaaa");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test successfully refusing actor descriptions that simply duplicate the actor name.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @small
|
|
|
|
*
|
2022-05-17 23:27:40 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testActorDescriptionValidationFailsOnDuplicatedActorNames():void {
|
|
|
|
|
|
|
|
$this->expectException(MDgenericInvalidInputsException::class);
|
|
|
|
NodaValidationHelper::validateActorDescription("Richard Lepsius", ["Lepsius, Richard"]);
|
|
|
|
$this->expectException(MDgenericInvalidInputsException::class);
|
|
|
|
NodaValidationHelper::validateActorDescription("Richard Lepsius", ["Lepsius", "Richard"]);
|
|
|
|
$this->expectException(MDgenericInvalidInputsException::class);
|
|
|
|
NodaValidationHelper::validateActorDescription("Lepsius, Richard", ["Lepsius", "Richard"]);
|
|
|
|
$this->expectException(MDgenericInvalidInputsException::class);
|
|
|
|
NodaValidationHelper::validateActorDescription("Richard Lepsius, ", ["Lepsius", "Richard"]);
|
|
|
|
$this->expectException(MDgenericInvalidInputsException::class);
|
|
|
|
NodaValidationHelper::validateActorDescription("Helmut Testtest", ["Helmut Testtest", "Helmut Testtest", "Testtest, Helmut", "Helmut", "Testtest"]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that a valid description is accepted.
|
|
|
|
*
|
2023-11-06 23:46:30 +01:00
|
|
|
* @small
|
|
|
|
*
|
2022-05-17 23:27:40 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testActorDescriptionValidationAcceptsValidDescription():void {
|
|
|
|
|
|
|
|
NodaValidationHelper::validateActorDescription("Richard Lepsius war ein Forscher", ["Lepsius", "Richard"]);
|
|
|
|
self::assertTrue(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|