Style code

* Fix errors and warnings from phpcs.
* Add commas at end of lines for arrays in PHP.
* Add space between // and comment.
* Add space between ) and {.
* Use tabs instead of spaces for indenting.
* Break lines in PHP with more than 100 characters.
* Remove double spaces and spaces at end of line.
* Remove spaces before comma.
* Fix some typos.

Change-Id: I9c014bdfa9832fa6a20d0190fe2fc668983d0fb9
This commit is contained in:
Fomafix 2015-03-14 15:49:04 +00:00 committed by [[mw:User:Fomafix]]
parent f691fbb8f2
commit d16dfb0ad5
11 changed files with 134 additions and 113 deletions

View file

@ -122,7 +122,8 @@ class WikiEditorHooks {
if ( !isset( $wgWikiEditorFeatures[$name] ) || $wgWikiEditorFeatures[$name]['global'] ) {
return true;
}
// Features with user preference control can have any number of preferences to be specific values to be enabled
// Features with user preference control can have any number of preferences
// to be specific values to be enabled
if ( $wgWikiEditorFeatures[$name]['user'] ) {
if ( isset( self::$features[$name]['requirements'] ) ) {
foreach ( self::$features[$name]['requirements'] as $requirement => $value ) {
@ -134,7 +135,8 @@ class WikiEditorHooks {
}
return true;
}
// Features controlled by $wgWikiEditorFeatures with both global and user set to false are awlways disabled
// Features controlled by $wgWikiEditorFeatures with both global and user
// set to false are always disabled
return false;
}
@ -336,7 +338,7 @@ class WikiEditorHooks {
if ( count( $configurations ) ) {
$vars = array_merge( $vars, $configurations );
}
//expose magic words for use by the wikieditor toolbar
// expose magic words for use by the wikieditor toolbar
WikiEditorHooks::getMagicWords( $vars );
return true;
}
@ -346,7 +348,8 @@ class WikiEditorHooks {
*
* Registers JavaScript test modules
*
* @param $testModules array of javascript testing modules. 'qunit' is fed using tests/qunit/QUnitTestResources.php.
* @param $testModules array of javascript testing modules. 'qunit' is fed using
* tests/qunit/QUnitTestResources.php.
* @param $resourceLoader object
* @return bool
*/
@ -383,7 +386,7 @@ class WikiEditorHooks {
* @param $vars array
* @return bool
*/
private static function getMagicWords( &$vars ){
private static function getMagicWords( &$vars ) {
$requiredMagicWords = array(
'redirect',
'img_right',
@ -474,19 +477,19 @@ class WikiEditorHooks {
if ( $status->value === EditPage::AS_CONFLICT_DETECTED ) {
$data['action.saveFailure.type'] = 'editConflict';
} else if ( $status->value === EditPage::AS_ARTICLE_WAS_DELETED ) {
} elseif ( $status->value === EditPage::AS_ARTICLE_WAS_DELETED ) {
$data['action.saveFailure.type'] = 'editPageDeleted';
} else if ( isset( $errors[0][0] ) && $errors[0][0] === 'abusefilter-disallowed' ) {
} elseif ( isset( $errors[0][0] ) && $errors[0][0] === 'abusefilter-disallowed' ) {
$data['action.saveFailure.type'] = 'extensionAbuseFilter';
} else if ( isset( $editPage->getArticle()->getPage()->ConfirmEdit_ActivateCaptcha ) ) {
} elseif ( isset( $editPage->getArticle()->getPage()->ConfirmEdit_ActivateCaptcha ) ) {
// TODO: :(
$data['action.saveFailure.type'] = 'extensionCaptcha';
} else if ( isset( $errors[0][0] ) && $errors[0][0] === 'spamprotectiontext' ) {
} elseif ( isset( $errors[0][0] ) && $errors[0][0] === 'spamprotectiontext' ) {
$data['action.saveFailure.type'] = 'extensionSpamBlacklist';
} else {
// Catch everything else... We don't seem to get userBadToken or
// userNewUser through this hook.
$data['action.saveFailure.type'] = 'responseUnknown';
// Catch everything else... We don't seem to get userBadToken or
// userNewUser through this hook.
$data['action.saveFailure.type'] = 'responseUnknown';
}
}
self::doEventLogging( $action, $article, $data );

View file

@ -30,7 +30,7 @@ $GLOBALS['wgWikiEditorFeatures'] = array(
// Adds a tab for previewing in-line
'preview' => array( 'global' => false, 'user' => true ),
// Adds a button and dialog for step-by-step publishing
// Adds a button and dialog for step-by-step publishing
'publish' => array( 'global' => false, 'user' => true ),
);
@ -152,7 +152,7 @@ $GLOBALS['wgResourceModules'] += array(
'jquery.wikiEditor',
'jquery.wikiEditor.toolbar.i18n',
'jquery.wikiEditor.toolbar',
)
),
),
'jquery.wikiEditor.toolbar.i18n' => $wikiEditorTpl + array(
'messages' => array(
@ -415,7 +415,7 @@ $GLOBALS['wgResourceModules'] += array(
'ext.wikiEditor',
'jquery.wikiEditor.toolbar',
'jquery.wikiEditor.toolbar.config',
)
),
),
'ext.wikiEditor.toolbar.styles' => $wikiEditorTpl + array(
'styles' => 'ext.wikiEditor.toolbar.styles.less',

View file

@ -599,7 +599,7 @@ $.wikiEditor.modules.dialogs.config = {
$( '#wikieditor-toolbar-link-int-target' ).suggestions();
// don't overwrite user's text
if ( selection !== '' ){
if ( selection !== '' ) {
$( '#wikieditor-toolbar-link-int-text' ).data( 'untouched', false );
}
@ -810,7 +810,7 @@ $.wikiEditor.modules.dialogs.config = {
if ( fileName !== '' ) {
fileTitle = new mw.Title( fileName );
// Append file namespace prefix to filename if not already contains it
if ( fileTitle.getNamespaceId() !== 6 ){
if ( fileTitle.getNamespaceId() !== 6 ) {
fileTitle = new mw.Title( fileName, 6 );
}
fileName = fileTitle.toText();

View file

@ -6,14 +6,14 @@
<!--[if gte IE 8]>
<style>
/* IE8 ONLY - This is how we are fixing the double-height of BR tags when they are alone in a P tag */
p > br {
p > br {
display: none;
}
p > br + br {
p > br + br {
display: block;
}
</style>
<![endif]-->
<![endif]-->
<style>
body {
margin: 0;

View file

@ -336,7 +336,7 @@ if ( !context || typeof context === 'undefined' ) {
return false;
}
}
var returnFromModules = null; //they return null by default
var returnFromModules = null; // they return null by default
// Pass the event around to all modules activated on this context
for ( var module in context.modules ) {
@ -347,7 +347,7 @@ if ( !context || typeof context === 'undefined' ) {
) {
var ret = $.wikiEditor.modules[module].evt[name]( context, event );
if ( ret !== null ) {
//if 1 returns false, the end result is false
// if 1 returns false, the end result is false
if ( returnFromModules === null ) {
returnFromModules = ret;
} else {

View file

@ -0,0 +1,68 @@
<?php
require_once 'WikiDialogsLinksSetup.php';
/**
* Description of WikiNewPageDialogs
*
* @author bhagyag, pdhanda
*
* This test case is part of the WikiEditorTestSuite.
* Configuration for these tests are documented as part of
* extensions/WikiEditor/tests/selenium/WikiEditorTestSuite.php
*
*/
class WikiDialogsLinks extends WikiDialogsLinksSetup {
// Set up the testing environment
function setup() {
parent::setUp();
parent::doCreateInternalTestPageIfMissing();
}
function tearDown() {
parent::doLogout();
parent::tearDown();
}
// Create a new page temporary
function createNewPage() {
parent::doOpenLink();
parent::login();
parent::doCreateNewPageTemporary();
}
// Add a internal link and verify
function testInternalLink() {
$this->createNewPage();
parent::verifyInternalLink();
}
// Add a internal link with different display text and verify
function testInternalLinkWithDisplayText() {
$this->createNewPage();
parent::verifyInternalLinkWithDisplayText();
}
// Add a internal link with blank display text and verify
function testInternalLinkWithBlankDisplayText() {
$this->createNewPage();
parent::verifyInternalLinkWithBlankDisplayText();
}
// Add external link and verify
function testExternalLink() {
$this->createNewPage();
parent::verifyExternalLink();
}
// Add external link with different display text and verify
function testExternalLinkWithDisplayText( ) {
$this->createNewPage();
parent::verifyExternalLinkWithDisplayText();
}
// Add external link with Blank display text and verify
function testExternalLinkWithBlankDisplayText() {
$this->createNewPage();
parent::verifyExternalLinkWithBlankDisplayText();
}
}

View file

@ -5,7 +5,7 @@ include( "WikiEditorConstants.php" );
* Date : Apr - 2010
* @author : BhagyaG - Calcey
*/
class WikiDialogs_Links_Setup extends SeleniumTestCase {
class WikiDialogsLinksSetup extends SeleniumTestCase {
// Open the page.
function doOpenLink() {
@ -34,14 +34,14 @@ class WikiDialogs_Links_Setup extends SeleniumTestCase {
// Create a temporary fixture page
function doCreateInternalTestPageIfMissing() {
$this->type( INPUT_SEARCH_BOX, WIKI_INTERNAL_LINK );
$this->type( INPUT_SEARCH_BOX, WIKI_INTERNAL_LINK );
$this->click( BUTTON_SEARCH );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->click( LINK_START . WIKI_INTERNAL_LINK );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$location = $this->getLocation() . "\n";
if ( strpos( $location, '&redlink=1' ) !== false ) {
$this->type( TEXT_EDITOR, "Test fixture page. No real content here" );
$location = $this->getLocation() . "\n";
if ( strpos( $location, '&redlink=1' ) !== false ) {
$this->type( TEXT_EDITOR, "Test fixture page. No real content here" );
$this->click( BUTTON_SAVE_WATCH );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->assertTrue( $this->isTextPresent( WIKI_INTERNAL_LINK ),
@ -51,7 +51,7 @@ class WikiDialogs_Links_Setup extends SeleniumTestCase {
// Create a temporary new page
function doCreateNewPageTemporary() {
$this->type( INPUT_SEARCH_BOX, WIKI_TEMP_NEWPAGE );
$this->type( INPUT_SEARCH_BOX, WIKI_TEMP_NEWPAGE );
$this->click( BUTTON_SEARCH );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->click( LINK_START . WIKI_TEMP_NEWPAGE );
@ -64,15 +64,24 @@ class WikiDialogs_Links_Setup extends SeleniumTestCase {
$this->click( LINK_ADDLINK );
$this->waitForPopup( 'addLink', WIKI_TEST_WAIT_TIME );
$this->type( TEXT_LINKNAME, ( WIKI_INTERNAL_LINK ) );
$this->assertTrue( $this->isElementPresent( ICON_PAGEEXISTS ), 'Element ' . ICON_PAGEEXISTS . 'Not found' );
$this->assertTrue(
$this->isElementPresent( ICON_PAGEEXISTS ),
'Element ' . ICON_PAGEEXISTS . 'Not found'
);
$this->assertEquals( "on", $this->getValue( OPT_INTERNAL ) );
$this->click( BUTTON_INSERTLINK );
$this->click( LINK_PREVIEW );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->assertEquals( ( WIKI_INTERNAL_LINK ), $this->getText( LINK_START . WIKI_INTERNAL_LINK ) );
$this->assertEquals(
( WIKI_INTERNAL_LINK ),
$this->getText( LINK_START . WIKI_INTERNAL_LINK )
);
$this->click( LINK_START . WIKI_INTERNAL_LINK );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->assertTrue( $this->isTextPresent( WIKI_INTERNAL_LINK ), $this->getText( TEXT_PAGE_HEADING ) );
$this->assertTrue(
$this->isTextPresent( WIKI_INTERNAL_LINK ),
$this->getText( TEXT_PAGE_HEADING )
);
}
// Add a internal link with different display text and verify
@ -81,7 +90,8 @@ class WikiDialogs_Links_Setup extends SeleniumTestCase {
$this->click( LINK_ADDLINK );
$this->waitForPopup( 'addLink', WIKI_TEST_WAIT_TIME );
$this->type( TEXT_LINKNAME, WIKI_INTERNAL_LINK );
$this->type ( TEXT_LINKDISPLAYNAME, WIKI_INTERNAL_LINK . TEXT_LINKDISPLAYNAME_APPENDTEXT );
$this->type( TEXT_LINKDISPLAYNAME,
WIKI_INTERNAL_LINK . TEXT_LINKDISPLAYNAME_APPENDTEXT );
$this->assertTrue( $this->isElementPresent( ICON_PAGEEXISTS ) );
$this->assertEquals( "on", $this->getValue( OPT_INTERNAL ) );
$this->click( BUTTON_INSERTLINK );
@ -91,8 +101,10 @@ class WikiDialogs_Links_Setup extends SeleniumTestCase {
$this->getText( LINK_START . WIKI_INTERNAL_LINK . TEXT_LINKDISPLAYNAME_APPENDTEXT ) );
$this->click( LINK_START . WIKI_INTERNAL_LINK . TEXT_LINKDISPLAYNAME_APPENDTEXT );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->assertTrue( $this->isTextPresent( WIKI_INTERNAL_LINK ), $this->getText( TEXT_PAGE_HEADING ) );
$this->assertTrue(
$this->isTextPresent( WIKI_INTERNAL_LINK ),
$this->getText( TEXT_PAGE_HEADING )
);
}
// Add a internal link with blank display text and verify
@ -124,8 +136,10 @@ class WikiDialogs_Links_Setup extends SeleniumTestCase {
$this->click( BUTTON_INSERTLINK );
$this->click( LINK_PREVIEW );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->assertEquals( WIKI_EXTERNAL_LINK, $this->getText( LINK_START . WIKI_EXTERNAL_LINK ) );
$this->assertEquals(
WIKI_EXTERNAL_LINK,
$this->getText( LINK_START . WIKI_EXTERNAL_LINK )
);
$this->click( LINK_START . WIKI_EXTERNAL_LINK );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->assertEquals( WIKI_EXTERNAL_LINK_TITLE, $this->getTitle() );
@ -142,10 +156,13 @@ class WikiDialogs_Links_Setup extends SeleniumTestCase {
$this->click( BUTTON_INSERTLINK );
$this->click( LINK_PREVIEW );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->assertEquals( WIKI_EXTERNAL_LINK_TITLE, $this->getText( LINK_START . WIKI_EXTERNAL_LINK_TITLE ) );
$this->assertEquals(
WIKI_EXTERNAL_LINK_TITLE,
$this->getText( LINK_START . WIKI_EXTERNAL_LINK_TITLE )
);
$this->click( LINK_START . ( WIKI_EXTERNAL_LINK_TITLE ) );
$this->waitForPageToLoad( WIKI_TEST_WAIT_TIME );
$this->assertEquals( WIKI_EXTERNAL_LINK_TITLE , $this->getTitle() );
$this->assertEquals( WIKI_EXTERNAL_LINK_TITLE, $this->getTitle() );
}
// Add external link with Blank display text and verify
@ -182,7 +199,7 @@ class WikiDialogs_Links_Setup extends SeleniumTestCase {
$WIKI_TABLE_ROW = $WIKI_TABLE_ROW + 1;
$this->assertTrue( $this->isElementPresent( TEXT_TABLEID_OTHER .
TEXT_VALIDATE_TABLE_PART1 . $WIKI_TABLE_ROW .
TEXT_VALIDATE_TABLE_PART2 . $WIKI_TABLE_COL .
TEXT_VALIDATE_TABLE_PART2 . $WIKI_TABLE_COL .
TEXT_VALIDATE_TABLE_PART3 ) );
}

View file

@ -1,67 +0,0 @@
<?php
require_once 'WikiDialogs_Links_Setup.php';
/**
* Description of WikiNewPageDialogs
*
* @author bhagyag, pdhanda
*
* This test case is part of the WikiEditorTestSuite.
* Configuration for these tests are dosumented as part of extensions/WikiEditor/tests/selenium/WikiEditorTestSuite.php
*
*/
class WikiDialogs_Links extends WikiDialogs_Links_Setup {
// Set up the testing environment
function setup() {
parent::setUp();
parent::doCreateInternalTestPageIfMissing();
}
function tearDown() {
parent::doLogout();
parent::tearDown();
}
// Create a new page temporary
function createNewPage() {
parent::doOpenLink();
parent::login();
parent::doCreateNewPageTemporary();
}
// Add a internal link and verify
function testInternalLink() {
$this->createNewPage();
parent::verifyInternalLink();
}
// Add a internal link with different display text and verify
function testInternalLinkWithDisplayText() {
$this->createNewPage();
parent::verifyInternalLinkWithDisplayText();
}
// Add a internal link with blank display text and verify
function testInternalLinkWithBlankDisplayText() {
$this->createNewPage();
parent::verifyInternalLinkWithBlankDisplayText();
}
// Add external link and verify
function testExternalLink() {
$this->createNewPage();
parent::verifyExternalLink();
}
// Add external link with different display text and verify
function testExternalLinkWithDisplayText( ) {
$this->createNewPage();
parent::verifyExternalLinkWithDisplayText();
}
// Add external link with Blank display text and verify
function testExternalLinkWithBlankDisplayText() {
$this->createNewPage();
parent::verifyExternalLinkWithBlankDisplayText();
}
}

View file

@ -1,7 +1,7 @@
<?php
define ( 'WIKI_TEST_WAIT_TIME', "3000" ); // Waiting time
// tool bar, buttons , links
// tool bar, buttons, links
// commonly using links
define ( 'LINK_MAIN_PAGE', "link=Main page" );
define ( 'LINK_RANDOM_PAGE', "link=Random article" );
@ -13,11 +13,13 @@ define ( 'LINK_PREVIEW', "wpPreview" );
define ( 'WIKI_SEARCH_PAGE', "Hair (musical)" ); // Page name to search
define ( 'WIKI_TEXT_SEARCH', "TV" ); // Text to search
define ( 'WIKI_INTERNAL_LINK', "Wikieditor-Fixture-Page" ); // Exisiting page name to add as an internal tag
// Existing page name to add as an internal tag
define ( 'WIKI_INTERNAL_LINK', "Wikieditor-Fixture-Page" );
define ( 'WIKI_EXTERNAL_LINK', "www.google.com" ); // External web site name
define ( 'WIKI_EXTERNAL_LINK_TITLE', "Google" ); // Page title of the external web site name
define ( 'WIKI_CODE_PATH', getcwd() ); // get the current path of the program
define ( 'WIKI_SCREENSHOTS_PATH', "screenshots" ); // the folder the error screen shots will be saved
// the folder the error screen shots will be saved
define ( 'WIKI_SCREENSHOTS_PATH', "screenshots" );
define ( 'WIKI_SCREENSHOTS_TYPE', "png" ); // screen print type
define ( 'WIKI_TEMP_NEWPAGE', "TestWikiPage" ); // temporary creating new page name
// for WikiCommonFunction_TC
@ -80,5 +82,3 @@ define ( 'BUTTON_CANCEL', "//button[4]" );
define ( 'TEXT_PREVIEW_TEXT1', "//div[@id='wikiPreview']/p[1]" );
define ( 'TEXT_PREVIEW_TEXT2', "//div[@id='wikiPreview']/p[2]" );
define ( 'TEXT_PREVIEW_TEXT3', "//div[@id='wikiPreview']/p[3]" );

View file

@ -5,7 +5,7 @@ class WikiEditorSeleniumConfig {
public static function getSettings( &$includeFiles, &$globalConfigs ) {
$includes = array(
'extensions/Vector/Vector.php',
'extensions/WikiEditor/WikiEditor.php'
'extensions/WikiEditor/WikiEditor.php'
);
$configs = array(
'wgDefaultSkin' => 'vector',

View file

@ -23,7 +23,7 @@ class WikiEditorTestSuite extends SeleniumTestSuite
}
public function addTests() {
$testFiles = array(
'extensions/WikiEditor/tests/selenium/WikiDialogs_Links.php'
'extensions/WikiEditor/tests/selenium/WikiDialogsLinks.php'
);
parent::addTestFiles( $testFiles );
}