Add validator for tag descriptions
This commit is contained in:
@ -5,19 +5,22 @@
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Small;
|
||||
|
||||
/**
|
||||
* This script contains tests for the validation of single field contents.
|
||||
*
|
||||
* @covers \NodaValidationHelper
|
||||
*/
|
||||
#[small]
|
||||
#[CoversClass(\NodaValidationHelper::class)]
|
||||
final class NodaValidationHelperTest extends TestCase {
|
||||
/**
|
||||
* Test that a specific error is thrown if no description for actors is provided.
|
||||
*
|
||||
* @small
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testActorDescriptionValidationFailsOnEmptyInput():void {
|
||||
@ -30,8 +33,6 @@ final class NodaValidationHelperTest extends TestCase {
|
||||
/**
|
||||
* Test successfully refusing too short actor descriptions.
|
||||
*
|
||||
* @small
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testActorDescriptionValidationFailsOnTooShortInput():void {
|
||||
@ -44,8 +45,6 @@ final class NodaValidationHelperTest extends TestCase {
|
||||
/**
|
||||
* Test successfully refusing actor descriptions that have too few distinct characters.
|
||||
*
|
||||
* @small
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testActorDescriptionValidationFailsOnTooFewDistinctCharacters():void {
|
||||
@ -58,8 +57,6 @@ final class NodaValidationHelperTest extends TestCase {
|
||||
/**
|
||||
* Test successfully refusing actor descriptions that simply duplicate the actor name.
|
||||
*
|
||||
* @small
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testActorDescriptionValidationFailsOnDuplicatedActorNames():void {
|
||||
@ -80,8 +77,6 @@ final class NodaValidationHelperTest extends TestCase {
|
||||
/**
|
||||
* Test that a valid description is accepted.
|
||||
*
|
||||
* @small
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testActorDescriptionValidationAcceptsValidDescription():void {
|
||||
@ -90,4 +85,68 @@ final class NodaValidationHelperTest extends TestCase {
|
||||
self::assertTrue(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a specific error is thrown if no description for tags is provided.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagDescriptionValidationFailsOnEmptyInput():void {
|
||||
|
||||
$this->expectException(MDInvalidEmptyInputException::class);
|
||||
NodaValidationHelper::validateTagDescription("");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test successfully refusing too short tag descriptions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagDescriptionValidationFailsOnTooShortInput():void {
|
||||
|
||||
$this->expectException(MDgenericInvalidInputsException::class);
|
||||
NodaValidationHelper::validateTagDescription("abc");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test successfully refusing tag descriptions that have too few distinct characters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagDescriptionValidationFailsOnTooFewDistinctCharacters():void {
|
||||
|
||||
$this->expectException(MDgenericInvalidInputsException::class);
|
||||
NodaValidationHelper::validateTagDescription("aaaaaaaaaaaa");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test successfully refusing tag descriptions that simply duplicate the tag name.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagDescriptionValidationFailsOnDuplicatedTagNames():void {
|
||||
|
||||
$this->expectException(MDgenericInvalidInputsException::class);
|
||||
NodaValidationHelper::validateTagDescription("Richard Lepsius", "Richard Lepsius");
|
||||
$this->expectException(MDgenericInvalidInputsException::class);
|
||||
NodaValidationHelper::validateTagDescription("Richard Lepsius", "Lepsius Richard");
|
||||
$this->expectException(MDgenericInvalidInputsException::class);
|
||||
NodaValidationHelper::validateTagDescription("Lepsius, Richard", "Lepsius, Richard");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a valid description is accepted.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagDescriptionValidationAcceptsValidDescription():void {
|
||||
|
||||
NodaValidationHelper::validateTagDescription("Richard Lepsius war ein Forscher", "Richard Lepsius");
|
||||
self::assertTrue(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user