*/
class SiteImporterTest extends PHPUnit_Framework_TestCase {
+ use MediaWikiCoversValidator;
+
private function newSiteImporter( array $expectedSites, $errorCount ) {
- $store = $this->getMock( 'SiteStore' );
+ $store = $this->getMockBuilder( 'SiteStore' )->getMock();
$store->expects( $this->once() )
->method( 'saveSites' )
->method( 'getSites' )
->will( $this->returnValue( new SiteList() ) );
- $errorHandler = $this->getMock( 'Psr\Log\LoggerInterface' );
+ $errorHandler = $this->getMockBuilder( 'Psr\Log\LoggerInterface' )->getMock();
$errorHandler->expects( $this->exactly( $errorCount ) )
->method( 'error' );
$importer = new SiteImporter( $store );
- $importer->setExceptionCallback( array( $errorHandler, 'error' ) );
+ $importer->setExceptionCallback( [ $errorHandler, 'error' ] );
return $importer;
}
$dewiki->setPath( MediaWikiSite::PATH_PAGE, 'http://de.wikipedia.org/wiki/' );
$dewiki->setSource( 'meta.wikimedia.org' );
- return array(
- 'empty' => array(
+ return [
+ 'empty' => [
'<sites></sites>',
- array(),
- ),
- 'no sites' => array(
+ [],
+ ],
+ 'no sites' => [
'<sites><Foo><globalid>Foo</globalid></Foo><Bar><quux>Bla</quux></Bar></sites>',
- array(),
- ),
- 'minimal' => array(
+ [],
+ ],
+ 'minimal' => [
'<sites>' .
'<site><globalid>Foo</globalid></site>' .
'</sites>',
- array( $foo ),
- ),
- 'full' => array(
+ [ $foo ],
+ ],
+ 'full' => [
'<sites>' .
'<site><globalid>Foo</globalid></site>' .
'<site>' .
'<path type="page_path">http://de.wikipedia.org/wiki/</path>' .
'</site>' .
'</sites>',
- array( $foo, $acme, $dewiki ),
- ),
- 'skip' => array(
+ [ $foo, $acme, $dewiki ],
+ ],
+ 'skip' => [
'<sites>' .
'<site><globalid>Foo</globalid></site>' .
'<site><barf>Foo</barf></site>' .
'<path type="link">http://acme.com/</path>' .
'</site>' .
'</sites>',
- array( $foo, $acme ),
+ [ $foo, $acme ],
1
- ),
- );
+ ],
+ ];
}
/**
public function testImportFromXML_malformed() {
$this->setExpectedException( 'Exception' );
- $store = $this->getMock( 'SiteStore' );
+ $store = $this->getMockBuilder( 'SiteStore' )->getMock();
$importer = new SiteImporter( $store );
$importer->importFromXML( 'THIS IS NOT XML' );
}
$dewiki->setPath( MediaWikiSite::PATH_PAGE, 'http://de.wikipedia.org/wiki/' );
$dewiki->setSource( 'meta.wikimedia.org' );
- $importer = $this->newSiteImporter( array( $foo, $acme, $dewiki ), 0 );
+ $importer = $this->newSiteImporter( [ $foo, $acme, $dewiki ], 0 );
$file = __DIR__ . '/SiteImporterTest.xml';
$importer->importFromFile( $file );
* @return array[]
*/
private function getSerializedSiteList( $sites ) {
- $serialized = array();
+ $serialized = [];
foreach ( $sites as $site ) {
$key = $site->getGlobalId();