35 $this->setExpectedException(
'InvalidArgumentException' );
42 $foo->setGlobalId(
'Foo' );
45 $acme->setGlobalId(
'acme.com' );
46 $acme->setGroup(
'Test' );
53 $exporter->exportSites( [ $foo, $acme ] );
56 $xml = fread( $tmp, 16 * 1024 );
58 $this->assertContains(
'<sites ', $xml );
59 $this->assertContains(
'<site>', $xml );
60 $this->assertContains(
'<globalid>Foo</globalid>', $xml );
61 $this->assertContains(
'</site>', $xml );
62 $this->assertContains(
'<globalid>acme.com</globalid>', $xml );
63 $this->assertContains(
'<group>Test</group>', $xml );
64 $this->assertContains(
'<localid type="interwiki">acme</localid>', $xml );
65 $this->assertContains(
'<path type="link">http://acme.com/</path>', $xml );
66 $this->assertContains(
'</sites>', $xml );
69 $xsdFile = __DIR__ .
'/../../../../docs/sitelist-1.0.xsd';
70 $xsdData = file_get_contents( $xsdFile );
72 $document =
new DOMDocument();
73 $document->loadXML( $xml, LIBXML_NONET );
74 $document->schemaValidateSource( $xsdData );
78 $store = $this->getMockBuilder(
'SiteStore' )->getMock();
80 $store->expects( $this->once() )
81 ->method(
'saveSites' )
82 ->will( $this->returnCallback(
function ( $moreSites )
use ( $sites ) {
83 foreach ( $moreSites
as $site ) {
88 $store->expects( $this->
any() )
89 ->method(
'getSites' )
90 ->will( $this->returnValue(
new SiteList() ) );
97 $foo->setGlobalId(
'Foo' );
100 $acme->setGlobalId(
'acme.com' );
101 $acme->setGroup(
'Test' );
106 $dewiki->setGlobalId(
'dewiki' );
107 $dewiki->setGroup(
'wikipedia' );
108 $dewiki->setForward(
true );
113 $dewiki->setSource(
'meta.wikimedia.org' );
121 new SiteList( [ $foo, $acme, $dewiki ] ),
133 $exporter->exportSites( $sites );
136 $xml = fread( $tmp, 16 * 1024 );
142 $importer->importFromXML( $xml );
144 $this->assertEquals( $sites, $actualSites );