|
7 | 7 | namespace PhpCfdi\CfdiCleaner\Tests\Features\XmlDocumentCleaners;
|
8 | 8 |
|
9 | 9 | use PhpCfdi\CfdiCleaner\Tests\TestCase;
|
| 10 | +use PhpCfdi\CfdiCleaner\Tests\Traits\UseSatNsRegistryTrait; |
10 | 11 | use PhpCfdi\CfdiCleaner\XmlDocumentCleaners\SetKnownSchemaLocations;
|
11 | 12 |
|
12 | 13 | final class SetKnownSchemaLocationsTest extends TestCase
|
13 | 14 | {
|
| 15 | + use UseSatNsRegistryTrait; |
| 16 | + |
14 | 17 | public function testSetKnownSchemaLocations(): void
|
15 | 18 | {
|
16 | 19 | $document = $this->createDocument(<<<XML
|
@@ -82,28 +85,24 @@ public function testSetKnownSchemaLocationsWithUnknownNamespace(): void
|
82 | 85 | $this->assertEquals($expected, $document);
|
83 | 86 | }
|
84 | 87 |
|
85 |
| - /** @noinspection PhpUnhandledExceptionInspection */ |
86 | 88 | public function testKnowAllLocationsFromSatNsRegistry(): void
|
87 | 89 | {
|
88 |
| - // obtain the list of known locations from phpcfdi/sat-ns-registry |
89 |
| - $satNsRegistryUrl = 'https://raw.githubusercontent.com/phpcfdi/sat-ns-registry/master/complementos_v1.json'; |
90 |
| - /** @var array<array{namespace: ?string, version: ?string, xsd: ?string}> $registry */ |
91 |
| - $registry = json_decode(file_get_contents($satNsRegistryUrl) ?: '[]', true, 512, JSON_THROW_ON_ERROR); |
| 90 | + $registry = $this->getSatNsRegistry(); |
92 | 91 |
|
93 | 92 | // re-create the known list of namespace#version => xsd-location
|
94 | 93 | $expected = [];
|
95 | 94 | foreach ($registry as $entry) {
|
96 |
| - $namespace = $entry['namespace'] ?? ''; |
97 |
| - $version = $entry['version'] ?? ''; |
98 |
| - $xsd = $entry['xsd'] ?? ''; |
| 95 | + $namespace = $entry->namespace ?? ''; |
| 96 | + $version = $entry->version ?? ''; |
| 97 | + $xsd = $entry->xsd ?? ''; |
99 | 98 | if ($namespace && $xsd) {
|
100 | 99 | $expected[$namespace . '#' . $version] = $xsd;
|
101 | 100 | }
|
102 | 101 | }
|
103 |
| - asort($expected); |
| 102 | + ksort($expected, SORT_STRING); |
104 | 103 |
|
105 | 104 | $knownLocations = SetKnownSchemaLocations::getKnownNamespaces();
|
106 |
| - asort($knownLocations); |
| 105 | + ksort($knownLocations, SORT_STRING); |
107 | 106 |
|
108 | 107 | $this->assertSame(
|
109 | 108 | $expected,
|
|
0 commit comments