@@ -99,9 +99,9 @@ public static function arrayToXmlC14NDataProvider(): array
9999 return self ::dataProvider ('testArrayToXmlC14N ' );
100100 }
101101
102- public static function arrayToXmlC14NWithIso88591EncodingDataProvider (): array
102+ public static function arrayToXmlC14NEncodedDataProvider (): array
103103 {
104- return self ::dataProvider ('testArrayToXmlC14NWithIso88591Encoding ' );
104+ return self ::dataProvider ('testArrayToXmlC14NEncoded ' );
105105 }
106106
107107 public static function xmlToArrayDataProvider (): array
@@ -119,9 +119,9 @@ public static function xmlToC14NDataProvider(): array
119119 return self ::dataProvider ('testXmlToC14N ' );
120120 }
121121
122- public static function xmlToC14NWithIso88591EncodingDataProvider (): array
122+ public static function xmlToC14NEncodedDataProvider (): array
123123 {
124- return self ::dataProvider ('testXmlToC14NWithIso88591Encoding ' );
124+ return self ::dataProvider ('testXmlToC14NEncoded ' );
125125 }
126126
127127 /**
@@ -201,21 +201,23 @@ public function testArrayToXmlC14N(
201201
202202 /**
203203 * Convierte un arreglo a un Xml y lo guarda como un string XML
204- * con testArrayToXmlC14NWithIso88591Encoding (), asegurando que la codificación
204+ * con testArrayToXmlC14NEncoded (), asegurando que la codificación
205205 * y contenido son correctos.
206206 */
207- #[DataProvider('arrayToXmlC14NWithIso88591EncodingDataProvider ' )]
208- public function testArrayToXmlC14NWithIso88591Encoding (
207+ #[DataProvider('arrayToXmlC14NEncodedDataProvider ' )]
208+ public function testArrayToXmlC14NEncoded (
209209 array $ data ,
210210 string $ expected ,
211- ?string $ expectedException
211+ ?string $ expectedException ,
212+ string $ encoding = 'UTF-8 '
212213 ): void {
213214 if ($ expectedException ) {
214215 $ this ->expectException ($ expectedException );
215216 }
216217
217218 $ xml = $ this ->xmlService ->encode ($ data );
218- $ xmlString = $ xml ->C14NWithIso88591Encoding ();
219+ $ xml ->setEncoding ($ encoding );
220+ $ xmlString = $ xml ->C14NEncoded ();
219221
220222 // Validar contenido.
221223 $ this ->assertSame ($ expected , $ xmlString );
@@ -306,30 +308,32 @@ public function testXmlToC14N(
306308
307309 /**
308310 * Convierte un string XML a un Xml y lo guarda como un string XML
309- * con C14NWithIso88591Encoding (), asegurando que la codificación y contenido
311+ * con C14NEncoded (), asegurando que la codificación y contenido
310312 * son correctos.
311313 */
312- #[DataProvider('xmlToC14NWithIso88591EncodingDataProvider ' )]
313- public function testXmlToC14NWithIso88591Encoding (
314+ #[DataProvider('xmlToC14NEncodedDataProvider ' )]
315+ public function testXmlToC14NEncoded (
314316 string $ xmlContent ,
315317 string $ expected ,
316- ?string $ expectedException
318+ ?string $ expectedException ,
319+ string $ encoding = 'UTF-8 '
317320 ): void {
318321 if ($ expectedException ) {
319322 $ this ->expectException ($ expectedException );
320323 }
321324
322325 $ doc = new XmlDocument ();
323326 $ doc ->loadXml ($ xmlContent );
324- $ xmlString = $ doc ->C14NWithIso88591Encoding ();
327+ $ doc ->setEncoding ($ encoding );
328+ $ xmlString = $ doc ->C14NEncoded ();
325329
326330 // Validar contenido.
327331 $ this ->assertSame ($ expected , $ xmlString );
328332
329333 // Validar codificación.
330334 $ this ->assertSame (
331- ' ISO-8859-1 ' ,
332- mb_detect_encoding ($ xmlString , ' ISO-8859-1 ' , true )
335+ $ encoding ,
336+ mb_detect_encoding ($ xmlString , $ encoding , true )
333337 );
334338 }
335339
0 commit comments