35 $store = $this->getMockBuilder(
'SiteStore' )->getMock();
37 $store->expects( $this->once() )
38 ->method(
'saveSites' )
39 ->will( $this->returnCallback(
function ( $sites )
use ( $expectedSites ) {
43 $store->expects( $this->
any() )
44 ->method(
'getSites' )
45 ->will( $this->returnValue(
new SiteList() ) );
47 $errorHandler = $this->getMockBuilder(
'Psr\Log\LoggerInterface' )->getMock();
48 $errorHandler->expects( $this->exactly( $errorCount ) )
52 $importer->setExceptionCallback( [ $errorHandler,
'error' ] );
67 $foo->setGlobalId(
'Foo' );
70 $acme->setGlobalId(
'acme.com' );
71 $acme->setGroup(
'Test' );
76 $dewiki->setGlobalId(
'dewiki' );
77 $dewiki->setGroup(
'wikipedia' );
78 $dewiki->setForward(
true );
83 $dewiki->setSource(
'meta.wikimedia.org' );
91 '<sites><Foo><globalid>Foo</globalid></Foo><Bar><quux>Bla</quux></Bar></sites>',
96 '<site><globalid>Foo</globalid></site>' .
102 '<site><globalid>Foo</globalid></site>' .
104 '<globalid>acme.com</globalid>' .
105 '<localid type="interwiki">acme</localid>' .
106 '<group>Test</group>' .
107 '<path type="link">http://acme.com/</path>' .
109 '<site type="mediawiki">' .
110 '<source>meta.wikimedia.org</source>' .
111 '<globalid>dewiki</globalid>' .
112 '<localid type="interwiki">wikipedia</localid>' .
113 '<localid type="equivalent">de</localid>' .
114 '<group>wikipedia</group>' .
116 '<path type="link">http://de.wikipedia.org/w/</path>' .
117 '<path type="page_path">http://de.wikipedia.org/wiki/</path>' .
120 [ $foo, $acme, $dewiki ],
124 '<site><globalid>Foo</globalid></site>' .
125 '<site><barf>Foo</barf></site>' .
127 '<globalid>acme.com</globalid>' .
128 '<localid type="interwiki">acme</localid>' .
129 '<silly>boop!</silly>' .
130 '<group>Test</group>' .
131 '<path type="link">http://acme.com/</path>' .
145 $importer->importFromXML( $xml );
149 $this->setExpectedException(
'Exception' );
151 $store = $this->getMockBuilder(
'SiteStore' )->getMock();
153 $importer->importFromXML(
'THIS IS NOT XML' );
158 $foo->setGlobalId(
'Foo' );
161 $acme->setGlobalId(
'acme.com' );
162 $acme->setGroup(
'Test' );
167 $dewiki->setGlobalId(
'dewiki' );
168 $dewiki->setGroup(
'wikipedia' );
169 $dewiki->setForward(
true );
174 $dewiki->setSource(
'meta.wikimedia.org' );
178 $file = __DIR__ .
'/SiteImporterTest.xml';
179 $importer->importFromFile( $file );
190 foreach ( $sites
as $site ) {
191 $key = $site->getGlobalId();