Skip to content

Commit 90be350

Browse files
JeroenDeDauwclaude
andcommitted
Test MappingName reserved-name and empty-name validation
MappingName gained a reserved "native" check (mirroring SchemaName) that had only indirect coverage. Add a direct unit test for the empty guard and the reserved name across casings — the invariant the projection listing now relies on to stay crash-free. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b94d95b commit 90be350

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
declare( strict_types = 1 );
4+
5+
namespace ProfessionalWiki\NeoWiki\Tests\Domain\Mapping;
6+
7+
use InvalidArgumentException;
8+
use PHPUnit\Framework\TestCase;
9+
use ProfessionalWiki\NeoWiki\Domain\Mapping\MappingName;
10+
11+
/**
12+
* @covers \ProfessionalWiki\NeoWiki\Domain\Mapping\MappingName
13+
*/
14+
class MappingNameTest extends TestCase {
15+
16+
public function testNonReservedMappingNameIsValid(): void {
17+
$mappingName = new MappingName( 'EDM' );
18+
19+
$this->assertSame( 'EDM', $mappingName->getText() );
20+
}
21+
22+
public function testEmptyMappingNameIsInvalid(): void {
23+
$this->expectException( InvalidArgumentException::class );
24+
25+
new MappingName( ' ' );
26+
}
27+
28+
/**
29+
* "native" is the built-in projection, so a Mapping page may not claim it, in any casing (MediaWiki
30+
* uppercases only the first title letter, so "Native" is the reachable form).
31+
*
32+
* @dataProvider reservedMappingNameProvider
33+
*/
34+
public function testReservedMappingNameIsInvalid( string $name ): void {
35+
$this->expectException( InvalidArgumentException::class );
36+
37+
new MappingName( $name );
38+
}
39+
40+
public static function reservedMappingNameProvider(): iterable {
41+
yield [ 'native' ];
42+
yield [ 'Native' ];
43+
yield [ 'NATIVE' ];
44+
yield [ 'nAtIvE' ];
45+
}
46+
47+
}

0 commit comments

Comments
 (0)