fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace Tests\Unit;
use App\Support\CheckedPattern;
use App\Support\StructuredData;
use Illuminate\Support\Collection;
use PHPUnit\Framework\TestCase;
use UnexpectedValueException;
class StructuredDataTest extends TestCase
{
public function test_collection_normalisation_preserves_keys_and_object_identity(): void
{
$row = (object) ['id' => 7];
$items = StructuredData::collectionItems(new Collection(['row' => $row]));
self::assertSame(['row' => $row], $items);
self::assertSame($row, $items['row']);
$generator = (static function () use ($row) {
yield 'row' => $row;
})();
self::assertSame(['row' => $row], StructuredData::collectionItems($generator));
}
public function test_invalid_scalar_cannot_be_recovered_as_an_empty_collection(): void
{
$this->expectException(UnexpectedValueException::class);
StructuredData::collectionItems('invalid structured snapshot');
}
public function test_invalid_unicode_fails_without_overwriting_the_source(): void
{
$source = "original\xFF";
try {
CheckedPattern::split('/\s+/u', $source);
self::fail('Malformed text must not be accepted as an empty result.');
} catch (\RuntimeException) {
self::assertSame("original\xFF", $source);
}
}
}