Add class NodaTagRelationIdentifier for parsing tag relation types from
input tag names
This commit is contained in:
50
tests/NodaTagRelationIdentifierTest.php
Normal file
50
tests/NodaTagRelationIdentifierTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Tests for the identification of tag relation types to objects based on input tag names.
|
||||
*
|
||||
* @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;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* This script contains tests for the uncertainty helper.
|
||||
*/
|
||||
#[small]
|
||||
#[CoversClass(\NodaTagRelationIdentifier::class)]
|
||||
final class NodaTagRelationIdentifierTest extends TestCase {
|
||||
/**
|
||||
* Returns input tag names with and without known suffixes signaling the relation type.
|
||||
*
|
||||
* @return array<array{0: string, 1: string, 2: false|MDTagRelationType}>
|
||||
*/
|
||||
public static function tagNameAndRelationTypeProvider():array {
|
||||
|
||||
return [
|
||||
'Delfin' => ["Delfin", "Delfin", false],
|
||||
'Delfin (Motiv)' => ["Delfin (Motiv)", "Delfin", MDTagRelationType::display_subject],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure times are correctly cleaned and parsed.
|
||||
*
|
||||
* @param string $term Term to check.
|
||||
* @param string $target_output Expected output name.
|
||||
* @param false|MDTagRelationType $target_type Expected identified relation type (or false for lack thereof).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[DataProvider('tagNameAndRelationTypeProvider')]
|
||||
public function testIdentificationWorksCorrectly(string $term, string $target_output, false|MDTagRelationType $target_type):void {
|
||||
|
||||
$identification = new NodaTagRelationIdentifier("de", $term);
|
||||
self::assertEquals($target_output, $identification->name);
|
||||
self::assertEquals($target_type, $identification->relation);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user