Paladox has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/268223

Change subject: Test
......................................................................

Test

Change-Id: I7274d3faeb7389c3166d574c2db7c76aa2ab46ff
---
M Wikidata.php
M extensions/Wikibase/repo/tests/phpunit/includes/api/ApiErrorReporterTest.php
2 files changed, 55 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata 
refs/changes/23/268223/1

diff --git a/Wikidata.php b/Wikidata.php
index 0610e8e..c253faf 100644
--- a/Wikidata.php
+++ b/Wikidata.php
@@ -4,7 +4,7 @@
 }
 
 // Jenkins stuff part1
-if ( PHP_SAPI === 'cli' && strpos( getenv( 'JOB_NAME' ), 
'mwext-Wikidata-testextension' ) !== false ) {
+if ( isset( $wgWikimediaJenkinsCI ) && $wgWikimediaJenkinsCI == true ) {
        // in future, run as non-experimental
        if ( !defined( 'WB_EXPERIMENTAL_FEATURES' ) || 
!WB_EXPERIMENTAL_FEATURES ) {
                define( 'WB_EXPERIMENTAL_FEATURES', true );
@@ -18,7 +18,9 @@
 $wgEnableWikibaseRepo = false;
 $wgEnableWikibaseClient = false;
 
-include_once __DIR__ . '/vendor/autoload.php';
+if ( file_exists(  __DIR__ . '/vendor/autoload.php' ) ) {
+       include_once __DIR__ . '/vendor/autoload.php';
+}
 
 if ( !empty( $wmgUseWikibaseRepo ) ) {
        include_once __DIR__ . '/extensions/Wikibase/repo/Wikibase.php';
@@ -45,7 +47,7 @@
 );
 
 // Jenkins stuff part2
-if ( PHP_SAPI === 'cli' && strpos( getenv( 'JOB_NAME' ), 
'mwext-Wikidata-testextension' ) !== false ) {
+if ( isset( $wgWikimediaJenkinsCI ) && $wgWikimediaJenkinsCI == true ) {
        //Jenkins always loads both so no need to check if they are loaded 
before getting settings
        require_once __DIR__ . '/extensions/Wikibase/repo/ExampleSettings.php';
        require_once __DIR__ . 
'/extensions/Wikibase/client/ExampleSettings.php';
diff --git 
a/extensions/Wikibase/repo/tests/phpunit/includes/api/ApiErrorReporterTest.php 
b/extensions/Wikibase/repo/tests/phpunit/includes/api/ApiErrorReporterTest.php
index 8458a42..4f08719 100644
--- 
a/extensions/Wikibase/repo/tests/phpunit/includes/api/ApiErrorReporterTest.php
+++ 
b/extensions/Wikibase/repo/tests/phpunit/includes/api/ApiErrorReporterTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Wikibase\Test;
+namespace Wikibase\Test\Repo\Api;
 
 use ApiMain;
 use DataValues\IllegalValueException;
@@ -8,13 +8,13 @@
 use Status;
 use UsageException;
 use ValueParsers\ParseException;
-use Wikibase\Api\ApiErrorReporter;
-use Wikibase\Lib\Localizer\DispatchingExceptionLocalizer;
-use Wikibase\Lib\Localizer\ExceptionLocalizer;
-use Wikibase\Lib\Localizer\ParseExceptionLocalizer;
+use Wikibase\ApiErrorReporter;
+use Wikibase\DispatchingExceptionLocalizer;
+use Wikibase\Localizer\ExceptionLocalizer;
+use Wikibase\Localizer\ParseExceptionLocalizer;
 
 /**
- * @covers Wikibase\Api\ApiErrorReporter
+ * @covers Wikibase\Repo\Api\ApiErrorReporter
  *
  * @group Wikibase
  * @group WikibaseValidators
@@ -26,7 +26,13 @@
  */
 class ApiErrorReporterTest extends \MediaWikiTestCase {
 
-       protected function assertUsageException( $info, $code, $httpStatusCode, 
$expectedDataFields, UsageException $ex ) {
+       protected function assertUsageException(
+               $info,
+               $code,
+               $httpStatusCode,
+               array $expectedDataFields,
+               UsageException $ex
+       ) {
                $messageArray = $ex->getMessageArray();
 
                $this->assertArrayHasKey( 'code', $messageArray );
@@ -44,11 +50,9 @@
                        $this->assertEquals( $httpStatusCode, $ex->getCode() );
                }
 
-               if ( $expectedDataFields ) {
-                       foreach ( $expectedDataFields as $path => $value ) {
-                               $path = explode( '/', $path );
-                               $this->assertValueAtPath( $value, $path, 
$messageArray );
-                       }
+               foreach ( $expectedDataFields as $path => $value ) {
+                       $path = explode( '/', $path );
+                       $this->assertValueAtPath( $value, $path, $messageArray 
);
                }
        }
 
@@ -109,7 +113,7 @@
                                '$expectedData' => array(
                                        'fruit' => 'Banana',
                                        'messages/0/name' => 
'wikibase-api-no-such-sitelink',
-                                       'messages/0/html/*' => '/gefunden/', // 
in German
+                                       'messages/0/html' => '/gefunden/', // 
in German
                                ),
                        ),
 
@@ -123,7 +127,7 @@
                                '$infoPattern' => '/^Malformed value\./',
                                '$expectedData' => array(
                                        'messages/0/name' => 
'wikibase-parse-error',
-                                       'messages/0/html/*' => '/Wert/', // in 
German
+                                       'messages/0/html' => '/Wert/', // in 
German
                                ),
                        ),
                );
@@ -132,7 +136,14 @@
        /**
         * @dataProvider exceptionProvider
         */
-       public function testDieException( $exception, $code, $httpStatusCode, 
$extradata, $infoPattern, $expectedDataFields ) {
+       public function testDieException(
+               $exception,
+               $code,
+               $httpStatusCode,
+               array $extradata = null,
+               $infoPattern,
+               array $expectedDataFields
+       ) {
                $api = new ApiMain();
                $localizer = $this->getExceptionLocalizer();
                $reporter = new ApiErrorReporter( $api, $localizer, 
Language::factory( 'de' ) );
@@ -159,7 +170,7 @@
                                '$infoPattern' => '/sitelink/',
                                '$expectedDataFields' => array(
                                        'messages/0/name' => 
'wikibase-api-no-such-sitelink',
-                                       'messages/0/html/*' => '/gefunden/', // 
in German
+                                       'messages/0/html' => '/gefunden/', // 
in German
                                        'messages/0/parameters/0' => '/Foo/',
                                ),
                        )
@@ -169,7 +180,7 @@
        /**
         * @dataProvider messageProvider
         */
-       public function testDieMessage( $code, $param, $infoPattern, 
$expectedDataFields ) {
+       public function testDieMessage( $code, $param, $infoPattern, array 
$expectedDataFields ) {
                $api = new ApiMain();
                $localizer = $this->getExceptionLocalizer();
                $reporter = new ApiErrorReporter( $api, $localizer, 
Language::factory( 'de' ) );
@@ -201,10 +212,10 @@
                                '$infoPattern' => '/sitelink/',
                                '$expectedData' => array(
                                        'messages/0/name' => 
'wikibase-api-no-such-sitelink',
-                                       'messages/0/html/*' => '/gefunden/', // 
in German
+                                       'messages/0/html' => '/gefunden/', // 
in German
                                        'messages/1/name' => 
'wikibase-noentity',
                                        'messages/1/parameters/0' => 'Q123',
-                                       'messages/1/html/*' => '/ist nicht 
vorhanden/', // in German
+                                       'messages/1/html' => '/ist nicht 
vorhanden/', // in German
                                ),
                        ),
 
@@ -226,7 +237,14 @@
        /**
         * @dataProvider statusProvider
         */
-       public function testDieStatus( Status $status, $code, $httpStatusCode, 
$extradata, $infoPattern, $expectedDataFields ) {
+       public function testDieStatus(
+               Status $status,
+               $code,
+               $httpStatusCode,
+               array $extradata = null,
+               $infoPattern,
+               array $expectedDataFields
+       ) {
                $api = new ApiMain();
                $localizer = $this->getExceptionLocalizer();
                $reporter = new ApiErrorReporter( $api, $localizer, 
Language::factory( 'de' ) );
@@ -273,7 +291,14 @@
        /**
         * @dataProvider errorProvider
         */
-       public function testDieError( $description, $code, $httpStatusCode, 
$extradata, $infoPattern, $expectedDataFields ) {
+       public function testDieError(
+               $description,
+               $code,
+               $httpStatusCode,
+               array $extradata,
+               $infoPattern,
+               array $expectedDataFields
+       ) {
                $api = new ApiMain();
                $localizer = $this->getExceptionLocalizer();
                $reporter = new ApiErrorReporter( $api, $localizer, 
Language::factory( 'de' ) );
@@ -297,9 +322,9 @@
                                '$status' => $status,
                                '$expectedData' => array(
                                        'warnings/main_int/messages/0/name' => 
'wikibase-conflict-patched',
-                                       'warnings/main_int/messages/0/html/*' 
=> '/Version/', // in German
+                                       'warnings/main_int/messages/0/html' => 
'/Version/', // in German
                                        'warnings/main_int/messages/1/name' => 
'undo-nochange',
-                                       'warnings/main_int/messages/1/html/*' 
=> '/Bearbeitung.*bereits/', // in German
+                                       'warnings/main_int/messages/1/html' => 
'/Bearbeitung.*bereits/', // in German
                                ),
                        ),
                );
@@ -308,14 +333,14 @@
        /**
         * @dataProvider warningProvider
         */
-       public function testReportStatusWarnings( Status $status, 
$expectedDataFields ) {
+       public function testReportStatusWarnings( Status $status, array 
$expectedDataFields ) {
                $api = new ApiMain();
                $localizer = $this->getExceptionLocalizer();
                $reporter = new ApiErrorReporter( $api, $localizer, 
Language::factory( 'de' ) );
 
                $reporter->reportStatusWarnings( $status );
 
-               $result = $api->getResult()->getData();
+               $result = $api->getResult()->getResultData();
 
                foreach ( $expectedDataFields as $path => $value ) {
                        $path = explode( '/', $path );

-- 
To view, visit https://gerrit.wikimedia.org/r/268223
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7274d3faeb7389c3166d574c2db7c76aa2ab46ff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikidata
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to