Lucie Kaffee has uploaded a new change for review. https://gerrit.wikimedia.org/r/151832
Change subject: minor fixes ...................................................................... minor fixes order of methods changed, no trailing spaces anymore, changed protected methods to private Change-Id: I9594e319837c724b9b429efc24c2a51f5676dd1a --- M repo/tests/phpunit/includes/api/ApiConventionsTest.php 1 file changed, 90 insertions(+), 99 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/32/151832/1 diff --git a/repo/tests/phpunit/includes/api/ApiConventionsTest.php b/repo/tests/phpunit/includes/api/ApiConventionsTest.php index e5511fa..181fc72 100644 --- a/repo/tests/phpunit/includes/api/ApiConventionsTest.php +++ b/repo/tests/phpunit/includes/api/ApiConventionsTest.php @@ -9,108 +9,12 @@ * @group WikibaseAPI * * @group medium - * + * * @licence GNU GPL v2+ * @author Lucie-Aimée Kaffee */ - - class ApiConventionsTest extends WikibaseApiTestCase { - - public function setUp() - { - parent::setUp(); - } - - - /** - * This method is for the assertions in particular for getFinalDescription as defined in ApiBase - * @param $moduleClass one of the modules in $GLOBALS['wgAPIModules'], only in this function for the error messages - * @param Module $module is an instance of $moduleClass - **/ - protected function assertGetFinalDescription ( $moduleClass, $module ) { - $method = 'getFinalDescription'; - $descArray = $module->$method(); - - $rMethod = new \ReflectionMethod($module, $method); - $this->assertTrue($rMethod->isPublic(), 'the method ' .$method .' of module ' .$moduleClass .' is not public'); - - $this->assertNotEmpty($module->$method(), 'the Module ' .$moduleClass .' does not have the method ' .$method); - $this->assertNotEmpty( $descArray, 'the array returned by the method ' .$method .' of module ' .$moduleClass .' is empty' ); - foreach ( $descArray as $i ) { - $this->assertTrue( is_string( $i ), 'the ' .$i .'. value returned by the method ' .$method .' of the module ' .$moduleClass .' is not a string' ); - } - } - - /** - * This method is for the assertions for getFinalParamDescription as defined in ApiBase, depending on getFinalParams - * @param $moduleClass one of the modules in $GLOBALS['wgAPIModules'], only in this function for the error messages - * @param Module $module is an instance of $moduleClass - **/ - protected function assertGetFinalParamDescription ( $moduleClass, $module ) { - $method = 'getFinalParamDescription'; - $paramsMethod = 'getFinalParams'; - $paramsArray = $module->$paramsMethod(); - if ( !empty( $paramsArray ) ) { - $paramDescArray = $module ->$method(); - $this->assertNotEmpty( $paramDescArray, 'the array returned by the method ' .$method .' of module ' .$moduleClass .' is empty' ); - - ////comparing the keys of the arrays of getParamDescription and getParams -> this assertion fails - //$arrayKeys = !array_diff_key( $paramDescArray, $paramsArray ) && !array_diff_key( $paramsArray, $paramDescArray ); - //$this->assertTrue( $arrayKeys, 'keys different at ' .$moduleClass ); - } - } - - /** - * This method is for the assertions for getFinalPossibleErrors as defined in ApiBase - * @param $moduleClass one of the modules in $GLOBALS['wgAPIModules'], only in this function for the error messages - * @param Module $module is an instance of $moduleClass - **/ - //TODO: compare if the messages here are existing Systemmessages - protected function assertGetFinalPossibleErrors ( $moduleClass, $module ) { - $method = 'getFinalPossibleErrors'; - $errArray = $module->$method(); - - $rMethod = new \ReflectionMethod($module, $method); - $this->assertTrue($rMethod->isPublic(), 'the method ' .$method .' of module ' .$moduleClass .' is not public'); - - $this->assertNotEmpty($module->$method(), 'the Module ' .$moduleClass .' does not have the method ' .$method); - - foreach ( $errArray as $subArr ) { - $this->assertNotEmpty( $subArr, 'the arry for the module ' .$moduleClass .' is empty' ); - - foreach ( $subArr as $key => $value ) { - //test always passes, even though it shouldn't - $bool = strcmp( $key, 'code' ) || strcmp( $key, 'info' ); - $this->assertTrue( $bool, $moduleClass .' ' .$key ); - } - } - } - - /** - * This method is for the assertions of getExamples as defined in ApiBase - * @param $moduleClass one of the modules in $GLOBALS['wgAPIModules'], only in this function for the error messages - * @param Module $module is an instance of $moduleClass - **/ - protected function assertGetExamples( $moduleClass, $module ) { - $method = 'getExamples'; - $rMethod = new \ReflectionMethod( $moduleClass, $method ); - $rMethod->setAccessible( true ); - $exArray = $rMethod->invoke( $module ); - - //there is a TODO in ParseValue- as soon as this is done, this if-statement can be deleted - if ( $moduleClass != 'Wikibase\Api\ParseValue' ) { - $this->assertNotEmpty( $exArray, 'there is an empty Array in ' .$moduleClass ); - - foreach ( $exArray as $key => $value ) { - $this->assertTrue( ( strpos( $key, 'api.php?action=' ) !== false ), 'the key ' .$key .' is not an url at ' .$moduleClass ); - $this->assertTrue( is_string( $value ), 'the value of the example for ' .$key .' in ' .$moduleClass .' is not a string' ); - } - - } - } - - /** + /** * Connects the assertions for the different methods and iterates through the api modules */ public function testApiConventions() { @@ -127,6 +31,93 @@ $this->assertGetExamples( $moduleClass, $module ); $this->assertGetFinalDescription($moduleClass, $module); $this->assertGetFinalPossibleErrors($moduleClass, $module); - } + } + } + + /** + * This method is for the assertions in particular for getFinalDescription as defined in ApiBase + * @param $moduleClass one of the modules in $GLOBALS['wgAPIModules'], only in this function for the error messages + * @param Module $module is an instance of $moduleClass + **/ + private function assertGetFinalDescription ( $moduleClass, $module ) { + $method = 'getFinalDescription'; + $descArray = $module->$method(); + + $rMethod = new \ReflectionMethod($module, $method); + $this->assertTrue($rMethod->isPublic(), 'the method ' .$method .' of module ' .$moduleClass .' is not public'); + + $this->assertNotEmpty($module->$method(), 'the Module ' .$moduleClass .' does not have the method ' .$method); + $this->assertNotEmpty( $descArray, 'the array returned by the method ' .$method .' of module ' .$moduleClass .' is empty' ); + foreach ( $descArray as $i ) { + $this->assertTrue( is_string( $i ), 'the ' .$i .'. value returned by the method ' .$method .' of the module ' .$moduleClass .' is not a string' ); + } + } + + /** + * This method is for the assertions for getFinalParamDescription as defined in ApiBase, depending on getFinalParams + * @param $moduleClass one of the modules in $GLOBALS['wgAPIModules'], only in this function for the error messages + * @param Module $module is an instance of $moduleClass + **/ + private function assertGetFinalParamDescription ( $moduleClass, $module ) { + $method = 'getFinalParamDescription'; + $paramsMethod = 'getFinalParams'; + $paramsArray = $module->$paramsMethod(); + if ( !empty( $paramsArray ) ) { + $paramDescArray = $module ->$method(); + $this->assertNotEmpty( $paramDescArray, 'the array returned by the method ' .$method .' of module ' .$moduleClass .' is empty' ); + + ////comparing the keys of the arrays of getParamDescription and getParams -> this assertion fails + //$arrayKeys = !array_diff_key( $paramDescArray, $paramsArray ) && !array_diff_key( $paramsArray, $paramDescArray ); + //$this->assertTrue( $arrayKeys, 'keys different at ' .$moduleClass ); + } + } + + /** + * This method is for the assertions for getFinalPossibleErrors as defined in ApiBase + * @param $moduleClass one of the modules in $GLOBALS['wgAPIModules'], only in this function for the error messages + * @param Module $module is an instance of $moduleClass + **/ + //TODO: compare if the messages here are existing Systemmessages + private function assertGetFinalPossibleErrors ( $moduleClass, $module ) { + $method = 'getFinalPossibleErrors'; + $errArray = $module->$method(); + + $rMethod = new \ReflectionMethod($module, $method); + $this->assertTrue($rMethod->isPublic(), 'the method ' .$method .' of module ' .$moduleClass .' is not public'); + + $this->assertNotEmpty($module->$method(), 'the Module ' .$moduleClass .' does not have the method ' .$method); + + foreach ( $errArray as $subArr ) { + $this->assertNotEmpty( $subArr, 'the arry for the module ' .$moduleClass .' is empty' ); + + foreach ( $subArr as $key => $value ) { + //test always passes, even though it shouldn't + $bool = strcmp( $key, 'code' ) || strcmp( $key, 'info' ); + $this->assertTrue( $bool, $moduleClass .' ' .$key ); + } + } + } + + /** + * This method is for the assertions of getExamples as defined in ApiBase + * @param $moduleClass one of the modules in $GLOBALS['wgAPIModules'], only in this function for the error messages + * @param Module $module is an instance of $moduleClass + **/ + private function assertGetExamples( $moduleClass, $module ) { + $method = 'getExamples'; + $rMethod = new \ReflectionMethod( $moduleClass, $method ); + $rMethod->setAccessible( true ); + $exArray = $rMethod->invoke( $module ); + + //there is a TODO in ParseValue- as soon as this is done, this if-statement can be deleted + if ( $moduleClass != 'Wikibase\Api\ParseValue' ) { + $this->assertNotEmpty( $exArray, 'there is an empty Array in ' .$moduleClass ); + + foreach ( $exArray as $key => $value ) { + $this->assertTrue( ( strpos( $key, 'api.php?action=' ) !== false ), 'the key ' .$key .' is not an url at ' .$moduleClass ); + $this->assertTrue( is_string( $value ), 'the value of the example for ' .$key .' in ' .$moduleClass .' is not a string' ); + } + + } } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/151832 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9594e319837c724b9b429efc24c2a51f5676dd1a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Lucie Kaffee <lucie.kaf...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits