[MediaWiki-commits] [Gerrit] Cleanup bits in SpecialSetLabelDescriptionAliasesTest - change (mediawiki...Wikibase)
jenkins-bot has submitted this change and it was merged. Change subject: Cleanup bits in SpecialSetLabelDescriptionAliasesTest .. Cleanup bits in SpecialSetLabelDescriptionAliasesTest * Fix type hints. * Split long lines. * Fix formatting. * Simplify private helper method calls. Change-Id: If7911bab6e5bf6b1fd09cad92b3fe528c54a84b6 --- M repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php 1 file changed, 19 insertions(+), 29 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php b/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php index bc05ff5..041b6de 100644 --- a/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php +++ b/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php @@ -35,7 +35,7 @@ */ class SpecialSetLabelDescriptionAliasesTest extends SpecialWikibaseRepoPageTestBase { - protected $languageCodes = array( 'en', 'de', 'de-ch', 'ii', 'zh' ); + private static $languageCodes = array( 'en', 'de', 'de-ch', 'ii', 'zh' ); /** * @see SpecialPageTestBase::newSpecialPage() @@ -68,7 +68,7 @@ return new FingerprintChangeOpFactory( new TermValidatorFactory( $maxLength, - $this-languageCodes, + self::$languageCodes, $this-getIdParser(), $this-getLabelDescriptionDuplicateDetector(), $this-mockRepository @@ -84,7 +84,7 @@ -disableOriginalConstructor() -getMock(); - $self = $this; // yay PHP 5.3 + $self = $this; $detector-expects( $this-any() ) -method( 'detectTermConflicts' ) -will( $this-returnCallback( function( @@ -139,20 +139,13 @@ * @return ContentLanguages */ private function getContentLanguages() { - $languages = $this-getMock( 'Wikibase\Lib\ContentLanguages' ); + $fake = $this-getMock( 'Wikibase\Lib\ContentLanguages' ); - $languages-expects( $this-any() ) - -method( 'getLanguages' ) - -will( $this-returnValue( $this-languageCodes ) ); - - $languageCodes = $this-languageCodes; // for PHP 5.3 - $languages-expects( $this-any() ) + $fake-expects( $this-any() ) -method( 'hasLanguage' ) - -will( $this-returnCallback( function( $code ) use ( $languageCodes ) { - return in_array( $code, $languageCodes ); - } ) ); + -will( $this-returnValue( true ) ); - return $languages; + return $fake; } /** @@ -162,7 +155,11 @@ * * @return Fingerprint */ - private function makeFingerprint( array $labels, array $descriptions, array $aliases ) { + private function makeFingerprint( + array $labels = array(), + array $descriptions = array(), + array $aliases = array() + ) { $fingerprint = new Fingerprint(); foreach ( $labels as $lang = $text ) { @@ -251,9 +248,7 @@ $withLanguageMatchers['label']['attributes']['value'] = 'foo'; $fooFingerprint = $this-makeFingerprint( - array( 'de' = 'foo' ), - array(), - array() + array( 'de' = 'foo' ) ); return array( @@ -295,9 +290,7 @@ new FauxRequest( array( 'language' = 'en', 'label' = 'FOO' ), true ), array(), $this-makeFingerprint( - array( 'de' = 'foo', 'en' = 'FOO' ), - array(), - array() + array( 'de' = 'foo', 'en' = 'FOO' ) ), ), @@ -307,9 +300,7 @@ new FauxRequest( array( 'language' = 'de', 'label' = 'FOO' ), true ), array(), $this-makeFingerprint( - array( 'de' = 'FOO' ), - array(), - array() + array( 'de' = 'FOO' )
[MediaWiki-commits] [Gerrit] Cleanup bits in SpecialSetLabelDescriptionAliasesTest - change (mediawiki...Wikibase)
Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/199260 Change subject: Cleanup bits in SpecialSetLabelDescriptionAliasesTest .. Cleanup bits in SpecialSetLabelDescriptionAliasesTest * Fix type hints. * Split long lines. * Fix formatting. * Simplify private helper method calls. Change-Id: If7911bab6e5bf6b1fd09cad92b3fe528c54a84b6 --- M repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php 1 file changed, 35 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/60/199260/1 diff --git a/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php b/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php index ef35947..96fb5b3 100644 --- a/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php +++ b/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php @@ -2,8 +2,10 @@ namespace Wikibase\Test; +use FauxRequest; use ValueValidators\Result; use WebRequest; +use WebResponse; use Wikibase\ChangeOp\FingerprintChangeOpFactory; use Wikibase\DataModel\Entity\EntityId; use Wikibase\DataModel\Entity\Item; @@ -35,7 +37,6 @@ class SpecialSetLabelDescriptionAliasesTest extends SpecialWikibaseRepoPageTestBase { protected $languageCodes = array( 'en', 'de', 'de-ch', 'ii', 'zh' ); - /** * @see SpecialPageTestBase::newSpecialPage() @@ -91,7 +92,7 @@ -disableOriginalConstructor() -getMock(); - $self = $this; // yay PHP 5.3 + $self = $this; $detector-expects( $this-any() ) -method( 'detectTermConflicts' ) -will( $this-returnCallback( function( @@ -117,7 +118,7 @@ * * @param string[] $terms * -* @return array +* @return UniquenessViolation[] */ public function detectDupes( $terms ) { $errors = array(); @@ -152,7 +153,7 @@ -method( 'getLanguages' ) -will( $this-returnValue( $this-languageCodes ) ); - $languageCodes = $this-languageCodes; // for PHP 5.3 + $languageCodes = $this-languageCodes; $languages-expects( $this-any() ) -method( 'hasLanguage' ) -will( $this-returnCallback( function( $code ) use ( $languageCodes ) { @@ -165,11 +166,15 @@ /** * @param string[] $labels * @param string[] $descriptions -* @param string[][] $aliases +* @param array[] $aliases * * @return Fingerprint */ - private function makeFingerprint( array $labels, array $descriptions, array $aliases ) { + private function makeFingerprint( + array $labels = array(), + array $descriptions = array(), + array $aliases = array() + ) { $fingerprint = new Fingerprint(); foreach ( $labels as $lang = $text ) { @@ -187,7 +192,7 @@ return $fingerprint; } - public function provideExecute() { + public function executeProvider() { $formMatchers['id'] = array( 'tag' = 'input', 'attributes' = array( @@ -256,9 +261,7 @@ $withLanguageMatchers['label']['attributes']['value'] = 'foo'; $fooFingerprint = $this-makeFingerprint( - array( 'de' = 'foo' ), - array(), - array() + array( 'de' = 'foo' ) ); return array( @@ -289,7 +292,7 @@ 'with id and language attribute' = array( $fooFingerprint, '$id', - new \FauxRequest( array( 'language' = 'de' ) ), + new FauxRequest( array( 'language' = 'de' ) ), $withLanguageMatchers, null ), @@ -297,43 +300,38 @@ 'add label' = array( $fooFingerprint, '$id', - new \FauxRequest( array( 'language' = 'en', 'label' = 'FOO' ), true ), + new FauxRequest( array( 'language' = 'en', 'label' = 'FOO' ), true ), array(), $this-makeFingerprint( - array( 'de' = 'foo', 'en' = 'FOO' ), - array(), -