X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fsite%2FSiteImporterTest.php;h=8a43bf8020dbce79bc23a139e1a04766abf597d5;hb=75160bdd3b4ac3642d147cda46e47c809999937d;hp=a49f06cfede1da59aaa0c151ddbc062f989827cc;hpb=87d3bd7afcec9a4149104bf34b892a5e78a73c5c;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/site/SiteImporterTest.php b/tests/phpunit/includes/site/SiteImporterTest.php index a49f06cfed..8a43bf8020 100644 --- a/tests/phpunit/includes/site/SiteImporterTest.php +++ b/tests/phpunit/includes/site/SiteImporterTest.php @@ -31,8 +31,10 @@ */ 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' ) @@ -44,12 +46,12 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { ->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; } @@ -82,22 +84,22 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { $dewiki->setPath( MediaWikiSite::PATH_PAGE, 'http://de.wikipedia.org/wiki/' ); $dewiki->setSource( 'meta.wikimedia.org' ); - return array( - 'empty' => array( + return [ + 'empty' => [ '', - array(), - ), - 'no sites' => array( + [], + ], + 'no sites' => [ 'FooBla', - array(), - ), - 'minimal' => array( + [], + ], + 'minimal' => [ '' . 'Foo' . '', - array( $foo ), - ), - 'full' => array( + [ $foo ], + ], + 'full' => [ '' . 'Foo' . '' . @@ -117,9 +119,9 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { 'http://de.wikipedia.org/wiki/' . '' . '', - array( $foo, $acme, $dewiki ), - ), - 'skip' => array( + [ $foo, $acme, $dewiki ], + ], + 'skip' => [ '' . 'Foo' . 'Foo' . @@ -131,10 +133,10 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { 'http://acme.com/' . '' . '', - array( $foo, $acme ), + [ $foo, $acme ], 1 - ), - ); + ], + ]; } /** @@ -148,7 +150,7 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { 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' ); } @@ -173,7 +175,7 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { $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 ); @@ -185,7 +187,7 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { * @return array[] */ private function getSerializedSiteList( $sites ) { - $serialized = array(); + $serialized = []; foreach ( $sites as $site ) { $key = $site->getGlobalId();