88use Soap \Wsdl \Loader \StreamWrapperLoader ;
99use Soap \Wsdl \Xml \Configurator \FlattenXsdImports ;
1010use VeeWee \Xml \Dom \Document ;
11+ use function VeeWee \Xml \Dom \Configurator \canonicalize ;
1112use function VeeWee \Xml \Dom \Configurator \comparable ;
1213
1314final class FlattenXsdImportsTest extends TestCase
@@ -16,47 +17,59 @@ final class FlattenXsdImportsTest extends TestCase
1617 *
1718 * @dataProvider provideTestCases
1819 */
19- public function test_it_can_flatten_xsd_imports (string $ wsdlUri , Document $ expected ): void
20+ public function test_it_can_flatten_xsd_imports (string $ wsdlUri , Document $ expected, callable $ xmlConfigurator ): void
2021 {
2122 $ wsdl = Document::fromXmlFile ($ wsdlUri );
2223 $ configurator = new FlattenXsdImports (
2324 $ wsdlUri ,
2425 FlatteningContext::forWsdl ($ wsdlUri , $ wsdl , new StreamWrapperLoader ())
2526 );
26- $ flattened = Document::fromUnsafeDocument ($ wsdl ->toUnsafeDocument (), $ configurator , comparable () );
27+ $ flattened = Document::fromUnsafeDocument ($ wsdl ->toUnsafeDocument (), $ configurator , $ xmlConfigurator );
2728
28- static ::assertSame ($ expected ->toXmlString (), $ flattened ->toXmlString ());
29+ static ::assertSame ($ expected ->reconfigure ( $ xmlConfigurator )-> toXmlString (), $ flattened ->toXmlString ());
2930 }
3031
3132 public function provideTestCases ()
3233 {
3334 yield 'single-xsd ' => [
3435 'wsdl ' => FIXTURE_DIR .'/flattening/single-xsd.wsdl ' ,
35- 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/single-xsd-result.wsdl ' , comparable ()),
36+ 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/single-xsd-result.wsdl ' ),
37+ comparable (),
3638 ];
3739 yield 'once-xsd ' => [
3840 'wsdl ' => FIXTURE_DIR .'/flattening/once-xsd.wsdl ' ,
39- 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/once-xsd-result.wsdl ' , comparable ()),
41+ 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/once-xsd-result.wsdl ' ),
42+ comparable (),
4043 ];
4144 yield 'multi-xsd ' => [
4245 'wsdl ' => FIXTURE_DIR .'/flattening/multi-xsd.wsdl ' ,
43- 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/multi-xsd-result.wsdl ' , comparable ()),
46+ 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/multi-xsd-result.wsdl ' ),
47+ comparable (),
4448 ];
4549 yield 'circular-xsd ' => [
4650 'wsdl ' => FIXTURE_DIR .'/flattening/circular-xsd.wsdl ' ,
47- 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/circular-xsd-result.wsdl ' , comparable ()),
51+ 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/circular-xsd-result.wsdl ' ),
52+ comparable (),
4853 ];
4954 yield 'redefine-xsd ' => [
5055 'wsdl ' => FIXTURE_DIR .'/flattening/redefine-xsd.wsdl ' ,
51- 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/redefine-xsd-result.wsdl ' , comparable ()),
56+ 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/redefine-xsd-result.wsdl ' ),
57+ comparable (),
5258 ];
5359 yield 'tnsless-xsd ' => [
5460 'wsdl ' => FIXTURE_DIR .'/flattening/tnsless-xsd.wsdl ' ,
55- 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/tnsless-xsd-result.wsdl ' , comparable ()),
61+ 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/tnsless-xsd-result.wsdl ' ),
62+ comparable (),
5663 ];
5764 yield 'grouped-xsd ' => [
5865 'wsdl ' => FIXTURE_DIR .'/flattening/grouped-xsd.wsdl ' ,
59- 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/grouped-xsd-result.wsdl ' , comparable ()),
66+ 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/grouped-xsd-result.wsdl ' ),
67+ comparable (),
68+ ];
69+ yield 'root-xmlns-import-issue ' => [
70+ 'wsdl ' => FIXTURE_DIR .'/flattening/root-xmlns-import-issue.wsdl ' ,
71+ 'expected ' => Document::fromXmlFile (FIXTURE_DIR .'/flattening/result/root-xmlns-import-issue-result.wsdl ' ),
72+ canonicalize (),
6073 ];
6174 }
6275}
0 commit comments