Umherirrender has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/355446 )
Change subject: Add phpcs and make pass
......................................................................
Add phpcs and make pass
Change-Id: I4861a329b957f1120ec2d95206598067b37cd352
---
M WikimediaEventsHooks.php
M composer.json
M includes/AuthManagerStatsdHandler.php
A phpcs.xml
M tests/browser/SearchSatisfactionTests.php
M tests/phpunit/AuthManagerStatsdHandlerTest.php
6 files changed, 411 insertions(+), 390 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents
refs/changes/46/355446/1
diff --git a/WikimediaEventsHooks.php b/WikimediaEventsHooks.php
index a1cb48b..8e54cd3 100644
--- a/WikimediaEventsHooks.php
+++ b/WikimediaEventsHooks.php
@@ -82,15 +82,16 @@
}
$isAPI = defined( 'MW_API' );
- $isMobile = class_exists( 'MobileContext' ) &&
MobileContext::singleton()->shouldDisplayMobileView();
+ $isMobile = class_exists( 'MobileContext' )
+ &&
MobileContext::singleton()->shouldDisplayMobileView();
$revId = $revision->getId();
$title = $article->getTitle();
- $event = array(
+ $event = [
'revisionId' => $revId,
'isAPI' => $isAPI,
'isMobile' => $isMobile,
- );
+ ];
if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
$event[ 'userAgent' ] = $_SERVER[ 'HTTP_USER_AGENT' ];
@@ -106,12 +107,11 @@
$editCount = $user->getEditCount();
-
// Check if this edit brings the user's total edit count to a
value
// that is a factor of ten. We consider these 'milestones'. The
rate
// at which editors are hitting such milestones and the time it
takes
// are important indicators of community health.
- if ( $editCount === 0 || preg_match( '/^9+$/' , "$editCount" )
) {
+ if ( $editCount === 0 || preg_match( '/^9+$/', "$editCount" ) )
{
$milestone = $editCount + 1;
$stats->increment( "editor.milestones.{$milestone}" );
$stats->timing(
"editor.milestones.timing.{$milestone}", $age );
@@ -120,7 +120,7 @@
// If the editor signed up in the last thirty days, and if this
is an
// NS_MAIN edit, log a NewEditorEdit event.
if ( $age <= 2592000 && $title->inNamespace( NS_MAIN ) ) {
- EventLogging::logEvent( 'NewEditorEdit', 6792669, array(
+ EventLogging::logEvent( 'NewEditorEdit', 6792669, [
'userId' => $user->getId(),
'userAge' => $age,
'editCount' => $editCount,
@@ -128,7 +128,7 @@
'revId' => $revId,
'isAPI' => $isAPI,
'isMobile' => $isMobile,
- ) );
+ ] );
}
return true;
@@ -166,26 +166,26 @@
$since = date( 'Ym' ) . '00000000';
$numMainspaceEditsThisMonth = $db->selectRowCount(
- array( 'revision', 'page' ),
+ [ 'revision', 'page' ],
'1',
- array(
+ [
'rev_user' => $user->getId(),
'rev_timestamp >= ' . $db->addQuotes(
$db->timestamp( $since ) ),
'page_namespace' => NS_MAIN,
- ),
+ ],
__FILE__ . ':' . __LINE__,
- array( 'LIMIT' => 6 ),
- array( 'page' => array( 'INNER JOIN', 'rev_page
= page_id' ) )
+ [ 'LIMIT' => 6 ],
+ [ 'page' => [ 'INNER JOIN', 'rev_page =
page_id' ] ]
);
if ( $numMainspaceEditsThisMonth === 5 ) {
$month = date( 'm-Y' );
MediaWikiServices::getInstance()
->getStatsdDataFactory()->increment(
'editor.activation.' . $month );
- EventLogging::logEvent( 'EditorActivation',
14208837, array(
+ EventLogging::logEvent( 'EditorActivation',
14208837, [
'userId' => $user->getId(),
'month' => $month,
- ) );
+ ] );
}
} );
}
@@ -212,23 +212,23 @@
// $clone is the current user object before the new
option values are set
$clone = User::newFromId( $user->getId() );
- $commonData = array(
+ $commonData = [
'version' => '1',
'userId' => $user->getId(),
'saveTimestamp' => wfTimestampNow(),
- );
+ ];
foreach ( $options as $optName => $optValue ) {
// loose comparision is required since some of
the values
// are not consistent in the two variables, eg,
'' vs false
if ( $clone->getOption( $optName ) != $optValue
) {
- $event = array(
+ $event = [
'property' => $optName,
// Encode value as JSON.
// This is parseable and allows
a consistent type for validation.
'value' => FormatJson::encode(
$optValue ),
'isDefault' =>
User::getDefaultOption( $optName ) == $optValue,
- ) + $commonData;
+ ] + $commonData;
EventLogging::logEvent( 'PrefUpdate',
5563398, $event );
}
}
@@ -249,14 +249,14 @@
*/
public static function onArticleDeleteComplete( WikiPage $article, User
$user, $reason, $id ) {
$title = $article->getTitle();
- EventLogging::logEvent( 'PageDeletion', 7481655, array(
+ EventLogging::logEvent( 'PageDeletion', 7481655, [
'userId' => $user->getId(),
'userText' => $user->getName(),
'pageId' => $id,
'namespace' => $title->getNamespace(),
'title' => $title->getDBkey(),
'comment' => $reason,
- ) );
+ ] );
return true;
}
@@ -272,7 +272,7 @@
*/
public static function onArticleUndelete( $title, $created, $comment,
$oldPageId ) {
global $wgUser;
- EventLogging::logEvent( 'PageRestoration', 7758372, array(
+ EventLogging::logEvent( 'PageRestoration', 7758372, [
'userId' => $wgUser->getId(),
'userText' => $wgUser->getName(),
'oldPageId' => $oldPageId,
@@ -280,7 +280,7 @@
'namespace' => $title->getNamespace(),
'title' => $title->getDBkey(),
'comment' => $comment,
- ) );
+ ] );
}
/**
@@ -299,14 +299,14 @@
protected static function logPageCreation( User $user, $pageId, Title
$title,
$revId ) {
- EventLogging::logEvent( 'PageCreation', 7481635, array(
+ EventLogging::logEvent( 'PageCreation', 7481635, [
'userId' => $user->getId(),
'userText' => $user->getName(),
'pageId' => $pageId,
'namespace' => $title->getNamespace(),
'title' => $title->getDBkey(),
'revId' => $revId,
- ) );
+ ] );
}
/**
@@ -323,8 +323,10 @@
* @param string $reason The reason that the title was moved
* @return bool true in all cases
*/
- public static function onTitleMoveComplete( Title $oldTitle, Title
$newTitle, User $user, $pageId, $redirectId, $reason ) {
- EventLogging::logEvent( 'PageMove', 7495717, array(
+ public static function onTitleMoveComplete( Title $oldTitle, Title
$newTitle, User $user,
+ $pageId, $redirectId, $reason
+ ) {
+ EventLogging::logEvent( 'PageMove', 7495717, [
'userId' => $user->getId(),
'userText' => $user->getName(),
'pageId' => $pageId,
@@ -334,7 +336,7 @@
'newTitle' => $newTitle->getDBkey(),
'redirectId' => $redirectId,
'comment' => $reason,
- ) );
+ ] );
if ( $redirectId !== 0 ) {
// The redirect was not suppressed, so log its creation.
@@ -382,14 +384,14 @@
$user = $out->getUser();
$title = $out->getTitle();
- EventLogging::logEvent( 'EditConflict', 8860941, array(
+ EventLogging::logEvent( 'EditConflict', 8860941, [
'userId' => $user->getId(),
'userText' => $user->getName(),
'pageId' => $title->getArticleID(),
'namespace' => $title->getNamespace(),
'title' => $title->getDBkey(),
'revId' => (int)$title->getLatestRevID(),
- ) );
+ ] );
return true;
}
@@ -457,9 +459,9 @@
public static function onSpecialSearchResults( $term, $titleMatches,
$textMatches ) {
global $wgOut;
- $wgOut->addJsConfigVars( array(
+ $wgOut->addJsConfigVars( [
'wgIsSearchResultPage' => true,
- ) );
+ ] );
return true;
}
@@ -491,11 +493,11 @@
// A/B test
$bucket = $request->getVal( 'bucket' );
- if ( !in_array( $bucket, array( '1', '2', '3', '4' ) ) ) {
+ if ( !in_array( $bucket, [ '1', '2', '3', '4' ] ) ) {
$bucket = null;
}
- $tags = array( 'cross-wiki-upload' );
+ $tags = [ 'cross-wiki-upload' ];
if ( $bucket ) {
$tags[] = "cross-wiki-upload-$bucket";
}
@@ -606,7 +608,7 @@
if ( array_key_exists( $param, $knownFilters ) &&
$value !== '' && $value !== null ) {
if ( $knownFilters[ $param ] === 'bool' ) {
$logData[ $param ] = (bool)$value;
- } else if ( $knownFilters[ $param ] ===
'integer' ) {
+ } elseif ( $knownFilters[ $param ] ===
'integer' ) {
$logData[ $param ] = (int)$value;
} else {
$logData[ $param ] = (string)$value;
diff --git a/composer.json b/composer.json
index d715b43..e6a9f5e 100644
--- a/composer.json
+++ b/composer.json
@@ -7,11 +7,14 @@
"facebook/webdriver": "1.1.1",
"symfony/css-selector": "3.1.0",
"jakub-onderka/php-parallel-lint": "0.9.2",
- "jakub-onderka/php-console-highlighter": "0.3.2"
+ "jakub-onderka/php-console-highlighter": "0.3.2",
+ "mediawiki/mediawiki-codesniffer": "0.7.2"
},
"scripts": {
+ "fix": "phpcbf",
"test": [
- "parallel-lint . --exclude vendor"
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
]
}
}
diff --git a/includes/AuthManagerStatsdHandler.php
b/includes/AuthManagerStatsdHandler.php
index b699de4..270c5f1 100644
--- a/includes/AuthManagerStatsdHandler.php
+++ b/includes/AuthManagerStatsdHandler.php
@@ -52,7 +52,7 @@
*/
public function handle( array $record ) {
$event = $this->getField( 'event', $record['context'] );
- $type = $this->getField( [ 'eventType', 'type' ] ,
$record['context'] );
+ $type = $this->getField( [ 'eventType', 'type' ],
$record['context'] );
$entrypoint = $this->getEntryPoint();
$status = $this->getField( 'status', $record['context'] );
$successful = $this->getField( 'successful', $record['context']
);
@@ -84,7 +84,7 @@
}
// some key parts can be null and will be removed by
array_filter
- $keyParts = array( 'authmanager', $event, $type, $entrypoint );
+ $keyParts = [ 'authmanager', $event, $type, $entrypoint ];
if ( $successful === true ) {
$keyParts[] = 'success';
} elseif ( $successful === false ) {
@@ -92,7 +92,6 @@
$keyParts[] = $error;
}
$key = implode( '.', array_filter( $keyParts ) );
-
// use of this class is set up in operations/mediawiki-config
so no nice dependency injection
$stats =
MediaWikiServices::getInstance()->getStatsdDataFactory();
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..ede6c5d
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset>
+ <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+ <file>.</file>
+ <arg name="extensions" value="php,php5,inc"/>
+ <arg name="encoding" value="utf8"/>
+ <exclude-pattern>vendor</exclude-pattern>
+ <exclude-pattern>node_modules</exclude-pattern>
+</ruleset>
diff --git a/tests/browser/SearchSatisfactionTests.php
b/tests/browser/SearchSatisfactionTests.php
index a18a61a..bbde015 100644
--- a/tests/browser/SearchSatisfactionTests.php
+++ b/tests/browser/SearchSatisfactionTests.php
@@ -26,7 +26,8 @@
* ~/bin/chromedriver &
* vagrant ssh -- -R 9515:localhost:9515
* From inside the vagrant session:
- * SELENIUM_BROWSER=chrome phpunit
/vagrant/mediawiki/extensions/WikimediaEvents/tests/browser/SearchSatisfactionTest.php
+ * SELENIUM_BROWSER=chrome phpunit
+ *
/vagrant/mediawiki/extensions/WikimediaEvents/tests/browser/SearchSatisfactionTest.php
*
* Specific tests can be run using phpunit's --filter argument against test
names:
* SELENIUM_BROWSER=firefox phpunit /.../SearchSatisfactionTest.php --filter
'full text search'
@@ -70,9 +71,10 @@
$url = '';
$capClass =
'Facebook\WebDriver\Remote\DesiredCapabilities';
if ( $browser && method_exists( $capClass, $browser ) )
{
- $cap = call_user_func( array( $capClass,
$browser ) );
+ $cap = call_user_func( [ $capClass, $browser ]
);
} else {
- throw new \RuntimeException( 'SELENIUM_BROWSER
environment var must be set to a known browser' );
+ throw new \RuntimeException(
+ 'SELENIUM_BROWSER environment var must
be set to a known browser' );
}
}
if ( getenv( 'SELENIUM_BROWSER_URL' ) ) {
@@ -99,7 +101,8 @@
$this->eventLoggingPath =
'/vagrant/logs/eventlogging.log';
}
if ( !is_file( $this->eventLoggingPath ) ) {
- throw new \RuntimeException( "Couldn't find
eventlogging.log. Please provide a path with MW_EVENT_LOG environment var" );
+ throw new \RuntimeException( "Couldn't find
eventlogging.log. " .
+ "Please provide a path with MW_EVENT_LOG
environment var" );
}
static $initializedSuggester = null;
@@ -109,230 +112,231 @@
if ( !$initializedSuggester ) {
// The autocomplete tests expect nothing more than
'Main Page' to exist, so
// no other setup is necessary.
- $this->apiCall(['action' => 'cirrus-suggest-index']);
+ $this->apiCall( [ 'action' => 'cirrus-suggest-index' ]
);
$initializedSuggester = true;
}
}
public function somethingProvider() {
- return array(
- "full text search click through" => array(
- array(
+ return [
+ "full text search click through" => [
+ [
$this->visitPage(
"Special:Search?search=main" ),
$this->clickSearchResult( 0 ),
- ),
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 0 ),
- ),
- ),
- "full text search ctrl-click through" => array(
- array(
+ ],
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 0 ],
+ ],
+ ],
+ "full text search ctrl-click through" => [
+ [
$this->visitPage(
"Special:Search?search=main" ),
$this->ctrlClickSearchResult( 0 ),
- ),
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 0 ),
- ),
- ),
- "full text search click through, back, click different
result" => array(
- array(
- $this->ensurePage('Something else',
'contains the word main in the content'),
+ ],
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 0 ],
+ ],
+ ],
+ "full text search click through, back, click different
result" => [
+ [
+ $this->ensurePage( 'Something else',
'contains the word main in the content' ),
$this->visitPage(
"Special:Search?search=main" ),
$this->clickSearchResult( 0 ),
$this->sleep( 2 ),
$this->clickBackButton(),
$this->clickSearchResult( 1 ),
- ),
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 0 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 1 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 1 ),
- ),
- ),
- "full text search redirect click through" => array(
- array(
+ ],
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 1 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 1 ],
+ ],
+ ],
+ "full text search redirect click through" => [
+ [
$this->ensurePage( "Redirect",
"#REDIRECT [[Main Page]]" ),
$this->visitPage(
"Special:Search?search=redirect&fulltext=1" ),
$this->clickRedirectSearchResult( 0 ),
- ),
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 0 ),
- )
- ),
- "full text search redirect ctrl-click through" => array(
- array(
+ ],
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 0 ],
+ ]
+ ],
+ "full text search redirect ctrl-click through" => [
+ [
$this->ensurePage( "Redirect",
"#REDIRECT [[Main Page]]" ),
$this->visitPage(
"Special:Search?search=redirect&fulltext=1" ),
$this->ctrlClickRedirectSearchResult( 0
),
- ),
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 0 ),
- )
- ),
- "full text search alt title click through" => array(
- array(
+ ],
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 0 ],
+ ]
+ ],
+ "full text search alt title click through" => [
+ [
$this->ensurePage( 'With Headings',
"Something\n==Role==\nmore content" ),
$this->visitPage(
"Special:Search?search=role" ),
$this->clickAltTitleSearchResult( 0 ),
- ),
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 0 ),
- )
- ),
- "full text search alt title ctrl-click through" =>
array(
- array(
+ ],
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 0 ],
+ ]
+ ],
+ "full text search alt title ctrl-click through" => [
+ [
$this->ensurePage( 'With Headings',
"Something\n==Role==\nmore content" ),
$this->visitPage(
"Special:Search?search=role" ),
$this->ctrlClickAltTitleSearchResult( 0
),
- ),
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 0 ),
- )
- ),
- "skin autocomplete click through" => array(
+ ],
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 0 ],
+ ]
+ ],
+ "skin autocomplete click through" => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "main"
),
$this->waitForSkinAutocomplete(),
$this->clickSkinAutocompleteResult( 0 ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- ),
- ),
- "skin autocomplete via enter key" => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ ],
+ ],
+ "skin autocomplete via enter key" => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "main"
),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete( "\n" ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- "skin autocomplete via click on 'containing...'" =>
array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ "skin autocomplete via click on 'containing...'" => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "main"
),
$this->waitForSkinAutocomplete(),
$this->clickSkinAutocompleteContaining(),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- "skin autocomplete via arrow up and enter on
'containing...'" => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ "skin autocomplete via arrow up and enter on
'containing...'" => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "main"
),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete(
WebDriverKeys::ARROW_UP . "\n" ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- "skin autocomplete via arrow down and enter" => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ "skin autocomplete via arrow down and enter" => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "main"
),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete(
WebDriverKeys::ARROW_DOWN . "\n" ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- ),
- ),
- "skin autocomplete via arrow down and magnifying glass"
=> array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ ],
+ ],
+ "skin autocomplete via arrow down and magnifying glass"
=> [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "main"
),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete(
WebDriverKeys::ARROW_DOWN ),
$this->clickMagnifyingGlass(),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- ),
- ),
- "skin autocomplete via typed exact match and enter" =>
array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ ],
+ ],
+ "skin autocomplete via typed exact match and enter" => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "Main
Page" ),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete( "\n" ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- ),
- ),
- "skin autocomplete via typed exact match and magnifying
glass" => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ ],
+ ],
+ "skin autocomplete via typed exact match and magnifying
glass" => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "Main
Page" ),
// the user might not do this, but it
makes the test more reliable
// to guarantee the SERP event comes in.
$this->waitForSkinAutocomplete(),
$this->clickMagnifyingGlass(),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- ),
- ),
- 'skin autocomplete selecting via down arrow, editing to
title match, wait for results, and press enter' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ ],
+ ],
+ 'skin autocomplete selecting via down arrow, editing to
title match, ' .
+ 'wait for results, and press enter' => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "Main
Page" ),
$this->waitForSkinAutocomplete(),
@@ -343,18 +347,18 @@
),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete( "\n" ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- ),
- ),
- 'skin autocomplete selecting via down arrow, editing to
title match, and press enter' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ ],
+ ],
+ 'skin autocomplete selecting via down arrow, editing to
title match, and press enter' => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "Main
Page" ),
$this->waitForSkinAutocomplete(),
@@ -363,262 +367,270 @@
str_repeat(
WebDriverKeys::BACKSPACE, 4 ) .
"page\n"
),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- ),
- ),
- 'skin autocomplete selecting via down arrow, editing to
non-title match, and press enter' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ ],
+ ],
+ 'skin autocomplete selecting via down arrow, editing to
non-title match, and press enter' => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "Main
Page" ),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete(
WebDriverKeys::ARROW_DOWN ),
$this->typeIntoSkinAutocomplete(
str_repeat( WebDriverKeys::BACKSPACE, 4 ) . "\n" ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- 'skin autocomplete selecting via down arrow, editing to
non-title match, and click magnifying glass' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ 'skin autocomplete selecting via down arrow, editing to
non-title match, ' .
+ 'and click magnifying glass' => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "Main
Page" ),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete(
WebDriverKeys::ARROW_DOWN ),
$this->typeIntoSkinAutocomplete(
str_repeat( WebDriverKeys::BACKSPACE, 4 ) ),
$this->clickMagnifyingGlass(),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- 'skin autocomplete selecting via down arrow, editing to
title match, and click magnifying glass' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ 'skin autocomplete selecting via down arrow, editing to
title match, ' .
+ 'and click magnifying glass' => [
// actions
- array(
+ [
$this->visitPage( "Main_Page" ),
$this->typeIntoSkinAutocomplete( "Main
Page" ),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete(
WebDriverKeys::ARROW_DOWN ),
$this->typeIntoSkinAutocomplete(
str_repeat( WebDriverKeys::BACKSPACE, 4 ) . "page" ),
$this->clickMagnifyingGlass(),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- ),
- ),
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ ],
+ ],
// Note that this test requires some page to exist with
the text 'mani page', or the
// did you mean will be rewritten automatically and
return search results for 'main page'
- 'full text search click the "did you mean" rewritten
result' => array(
+ 'full text search click the "did you mean" rewritten
result' => [
// actions
- array(
+ [
$this->visitPage(
"Special:Search?search=mani%20page" ),
// if the button is clicked too quickly
the event doesn't fire because
// js hasn't loaded.
$this->sleep( 2 ),
$this->clickDidYouMeanRewritten(),
$this->sleep( 2 ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null, 'inputLocation' => null,
'didYouMeanVisible' => 'autorewrite' ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null, 'inputLocation' => 'dym-rewritten',
'didYouMeanVisible' => 'no' ),
- ),
- ),
- 'full text search click the "did you mean" original
result' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null,
+ 'inputLocation' => null,
'didYouMeanVisible' => 'autorewrite' ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null,
+ 'inputLocation' =>
'dym-rewritten', 'didYouMeanVisible' => 'no' ],
+ ],
+ ],
+ 'full text search click the "did you mean" original
result' => [
// actions
- array(
+ [
$this->visitPage(
"Special:Search?search=mani%20page" ),
// if the button is clicked too quickly
the event doesn't fire because
// js hasn't loaded.
$this->sleep( 2 ),
$this->clickDidYouMeanOriginal(),
$this->sleep( 2 ),
- ),
+ ],
// expected events
- array(
+ [
// @TODO the did you mean should be
integrated and trigger some click event
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null, 'inputLocation' => null,
'didYouMeanVisible' => 'autorewrite' ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null, 'inputLocation' => 'dym-original',
'didYouMeanVisible' => 'yes' ),
- ),
- ),
- 'full text search click the "did you mean" suggestion
result' => array(
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null,
+ 'inputLocation' => null,
'didYouMeanVisible' => 'autorewrite' ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null,
+ 'inputLocation' =>
'dym-original', 'didYouMeanVisible' => 'yes' ],
+ ],
+ ],
+ 'full text search click the "did you mean" suggestion
result' => [
// actions
- array(
+ [
$this->ensurePage( "Misspelled", "main
paeg" ),
$this->visitPage(
"Special:Search?search=main%20paeg" ),
// if the button is clicked too quickly
the event doesn't fire because
// js hasn't loaded.
$this->sleep( 2 ),
$this->clickDidYouMeanSuggestion(),
- ),
+ ],
// expected events
- array(
+ [
// @TODO the did you mean should be
integrated and trigger some click event
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null, 'inputLocation' => null,
'didYouMeanVisible' => 'yes' ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null, 'inputLocation' => 'dym-suggest',
'didYouMeanVisible' => 'no' ),
- ),
- ),
- 'Special:Search bar type then enter' => array(
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null,
+ 'inputLocation' => null,
'didYouMeanVisible' => 'yes' ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null,
+ 'inputLocation' =>
'dym-suggest', 'didYouMeanVisible' => 'no' ],
+ ],
+ ],
+ 'Special:Search bar type then enter' => [
// actions
- array(
+ [
$this->visitPage( 'Special:Search' ),
$this->typeIntoSearchAutocomplete(
"main" ),
$this->waitForSearchAutocomplete(),
$this->typeIntoSearchAutocomplete( "\n"
),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- 'Special:Search bar type, arrow down, enter' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ 'Special:Search bar type, arrow down, enter' => [
// actions
- array(
+ [
$this->visitPage( 'Special:Search' ),
$this->typeIntoSearchAutocomplete(
"main" ),
$this->waitForSearchAutocomplete(),
$this->typeIntoSearchAutocomplete(
WebDriverKeys::ARROW_DOWN . "\n" ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- 'Special:Search bar type, click result with mouse' =>
array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ 'Special:Search bar type, click result with mouse' => [
// actions
- array(
+ [
$this->visitPage( 'Special:Search' ),
$this->typeIntoSearchAutocomplete(
'main' ),
$this->waitForSearchAutocomplete(),
$this->clickSearchAutocompleteResult( 0
),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- 'full text search ctrl-click for new tab' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ 'full text search ctrl-click for new tab' => [
// actions
- array(
+ [
$this->visitPage(
'Special:Search?search=main' ),
$this->ctrlClickSearchResult( 0 ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'fulltext', 'position' => 0 ),
- ),
- ),
- 'skin autocomplete ctrl-click result for new tab' =>
array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'fulltext', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'fulltext', 'position' => 0 ],
+ ],
+ ],
+ 'skin autocomplete ctrl-click result for new tab' => [
// actions
- array(
+ [
$this->visitPage( 'Special:Search' ),
$this->typeIntoSkinAutocomplete( 'main'
),
$this->waitForSkinAutocomplete(),
$this->ctrlClickSkinAutocompleteResult(
0 ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- ),
- ),
- 'skin autocomplete arrow down and ctrl-click result for
new tab' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ ],
+ ],
+ 'skin autocomplete arrow down and ctrl-click result for
new tab' => [
// actions
- array(
+ [
$this->visitPage( 'Special:Search' ),
$this->typeIntoSkinAutocomplete( 'main'
),
$this->waitForSkinAutocomplete(),
$this->typeIntoSkinAutocomplete(
WebDriverKeys::ARROW_DOWN ),
$this->ctrlClickSkinAutocompleteResult(
0 ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- ),
- ),
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ ],
+ ],
// This test is a bit odd because the ctrl-click
doesn't trigger a new tab,
// it gets eaten by the ooui widget and a search is
performed in the browser
- 'Special:Search autocomplete ctrl-click result' =>
array(
+ 'Special:Search autocomplete ctrl-click result' => [
// actions
- array(
+ [
$this->visitPage( 'Special:Search' ),
- $this->typeIntoSearchAutocomplete(
'main '),
+ $this->typeIntoSearchAutocomplete(
'main ' ),
$this->waitForSearchAutocomplete(),
$this->ctrlClickSearchAutocompleteResult( 0 ),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => 0 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- 'skin autocomplete non-exact match ctrl-click
magnifying glass for new tab' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => 0 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ 'skin autocomplete non-exact match ctrl-click
magnifying glass for new tab' => [
// actions
- array(
+ [
$this->visitPage( 'Main_Page' ),
$this->typeIntoSkinAutocomplete( 'main'
),
$this->waitForSkinAutocomplete(),
$this->ctrlClickMagnifyingGlass(),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- array( 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ),
- ),
- ),
- 'skin autocomplete exact match ctrl-click magnifying
glass for new tab' => array(
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'searchResultPage',
'source' => 'fulltext', 'position' => null ],
+ ],
+ ],
+ 'skin autocomplete exact match ctrl-click magnifying
glass for new tab' => [
// actions
- array(
+ [
$this->visitPage( 'Main_Page' ),
$this->typeIntoSkinAutocomplete( 'main
page' ),
$this->waitForSkinAutocomplete(),
$this->ctrlClickMagnifyingGlass(),
- ),
+ ],
// expected events
- array(
- array( 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ),
- array( 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ),
- array( 'action' => 'visitPage',
'source' => 'autocomplete', 'position' => -1 ),
- ),
- ),
- );
+ [
+ [ 'action' => 'searchResultPage',
'source' => 'autocomplete', 'position' => null ],
+ [ 'action' => 'click', 'source' =>
'autocomplete', 'position' => -1 ],
+ [ 'action' => 'visitPage', 'source' =>
'autocomplete', 'position' => -1 ],
+ ],
+ ],
+ ];
}
/**
@@ -650,10 +662,10 @@
$wantedKeys = array_flip( array_keys( reset( $expectedEvents )
) );
$defaults = array_combine(
array_keys( $wantedKeys ),
- array_fill(0, count( $wantedKeys ), null )
+ array_fill( 0, count( $wantedKeys ), null )
);
- $finalEvents = array();
- $seen = array();
+ $finalEvents = [];
+ $seen = [];
foreach ( $actualEvents as $idx => $envelope ) {
$actualEvent = $envelope['event'];
// Only concerned with satisfaction events
@@ -707,7 +719,7 @@
private function collectEvents( $prevPosition ) {
$log = file_get_contents( $this->eventLoggingPath );
- $events = array();
+ $events = [];
foreach ( explode( "\n", substr( $log, $prevPosition ) ) as
$line ) {
if ( trim( $line ) ) {
$events[] = json_decode( $line, true );
@@ -723,7 +735,6 @@
};
}
-
protected function waitForSkinAutocomplete() {
return function ( $webDriver ) {
$webDriver->wait()->until(
@@ -736,7 +747,7 @@
protected function typeIntoSkinAutocomplete( $chars ) {
return function ( $webDriver ) use ( $chars ) {
- sleep(1);
+ sleep( 1 );
$webDriver->findElement( WebDriverBy::id( 'searchInput'
) )->sendKeys( $chars );
};
}
@@ -913,16 +924,15 @@
};
}
-
protected function getContent( $title ) {
$url = 'http://localhost:8080/w/api.php';
- $response = $this->apiCall( array(
+ $response = $this->apiCall( [
'titles' => $title,
'action' => 'query',
'prop' => 'revisions',
'rvlimit' => 1,
'rvprop' => 'content',
- ) );
+ ] );
if ( empty( $response['query']['pages'] ) ) {
return null;
}
@@ -935,7 +945,7 @@
}
protected function ensurePage( $title, $content ) {
- static $seen = array();
+ static $seen = [];
return function () use ( $title, $content, &$seen ) {
// makes bold assumption title/content will always match
if ( isset( $seen[$title] ) ) {
@@ -947,17 +957,17 @@
if ( trim( $content ) === trim( $currentContent ) ) {
return;
}
- $response = $this->apiCall( array(
+ $response = $this->apiCall( [
'action' => 'query',
'meta' => 'tokens',
- ) );
- $response = $this->apiCall( array(), array(
+ ] );
+ $response = $this->apiCall( [], [
'action' => 'edit',
'title' => $title,
'text' => $content,
'summary' => 'automated WikimediaEvents browser
test edit',
'token' =>
$response['query']['tokens']['csrftoken'],
- ) );
+ ] );
// give time for jobs to work their way through
sleep( 10 );
};
@@ -965,22 +975,22 @@
protected function apiCall( array $params, $postData = null ) {
if ( $postData ) {
- $context = stream_context_create( array(
- 'http' => array(
+ $context = stream_context_create( [
+ 'http' => [
'method' => 'POST',
'header' => 'Content-type:
application/x-www-form-urlencoded',
'content' => http_build_query(
$postData ),
- ),
- ) );
+ ],
+ ] );
} else {
$context = null;
}
$apiUrl = str_replace( '/wiki/', '/w/api.php', self::$mwBaseUrl
);
- return json_decode( file_get_contents( $apiUrl . '?' .
http_build_query( $params + array(
+ return json_decode( file_get_contents( $apiUrl . '?' .
http_build_query( $params + [
'format' => 'json',
'formatversion' => 2,
- ) ), false, $context ), true );
+ ] ), false, $context ), true );
}
/**
diff --git a/tests/phpunit/AuthManagerStatsdHandlerTest.php
b/tests/phpunit/AuthManagerStatsdHandlerTest.php
index 5cc516b..19478c2 100644
--- a/tests/phpunit/AuthManagerStatsdHandlerTest.php
+++ b/tests/phpunit/AuthManagerStatsdHandlerTest.php
@@ -7,7 +7,7 @@
* @dataProvider provideHandle
*/
public function testHandle( $record, $expectedKey ) {
- $stats = $this->getMock ( StatsdDataFactory::class );
+ $stats = $this->getMock( StatsdDataFactory::class );
$this->setService( 'StatsdDataFactory', $stats );
$handler = $this->getMockBuilder(
AuthManagerStatsdHandler::class )
->setMethods( [ 'getEntryPoint' ] )->getMock();
@@ -28,72 +28,70 @@
$multiStatus->fatal( 'bar' );
return [
- 'no event' => [ [
+ 'no event' => [ [
'channel' => 'authmanager',
'context' => [ 'foo' => 'bar' ],
], null ],
- 'wrong type' => [ [
+ 'wrong type' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate', 'type'
=> Status::newGood() ],
], null ],
- 'right channel' => [ [
+ 'right channel' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate' ],
], 'authmanager.autocreate' ],
- 'old channel' => [ [
+ 'old channel' => [ [
'channel' => 'authmanager',
'context' => [ 'event' => 'autocreate' ],
], 'authmanager.autocreate' ],
- 'wrong channel' => [ [
+ 'wrong channel' => [ [
'channel' => 'authentication',
'context' => [ 'event' => 'autocreate' ],
], null ],
-
- 'simple' => [ [
+ 'simple' => [ [
'channel' => 'authevents',
- 'context' => [ 'event' => 'autocreate' ],
+ 'context' => [ 'event' => 'autocreate' ],
], 'authmanager.autocreate' ],
- 'type' => [ [
+ 'type' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate',
'eventType' => 'session' ],
], 'authmanager.autocreate.session' ],
- 'type fallback' => [ [
+ 'type fallback' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate', 'type'
=> 'session' ],
], 'authmanager.autocreate.session' ],
- 'success' => [ [
+ 'success' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate',
'successful' => true ],
], 'authmanager.autocreate.success' ],
- 'failure' => [ [
+ 'failure' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate',
'successful' => false ],
], 'authmanager.autocreate.failure' ],
- 'success with status' => [ [
+ 'success with status' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate',
'successful' => true, 'status' => 'snafu' ],
], 'authmanager.autocreate.success' ],
- 'failure with status' => [ [
+ 'failure with status' => [ [
'channel' => 'authevents',
- 'context' => [ 'event' => 'autocreate',
'successful' => false, 'status' => 'snafu' ],
+ 'context' => [ 'event' => 'autocreate',
'successful' => false, 'status' => 'snafu' ],
], 'authmanager.autocreate.failure.snafu' ],
-
- 'Status, good' => [ [
+ 'Status, good' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate',
'status' => Status::newGood() ],
], 'authmanager.autocreate.success' ],
- 'Status, bad' => [ [
+ 'Status, bad' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate',
'status' => Status::newFatal( 'snafu' ) ],
], 'authmanager.autocreate.failure.snafu' ],
- 'Status, multiple' => [ [
+ 'Status, multiple' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate',
'status' => $multiStatus ],
], 'authmanager.autocreate.failure.foo' ],
- 'StatusValue' => [ [
+ 'StatusValue' => [ [
'channel' => 'authevents',
'context' => [ 'event' => 'autocreate',
'status' => StatusValue::newGood() ],
], 'authmanager.autocreate.success' ],
--
To view, visit https://gerrit.wikimedia.org/r/355446
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4861a329b957f1120ec2d95206598067b37cd352
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits