Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 5743275

Browse files
author
Jamie Snape
committed
Fix failing style tests
1 parent ff58016 commit 5743275

File tree

6 files changed

+45
-41
lines changed

6 files changed

+45
-41
lines changed

core/controllers/components/UtilityComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ static function run_query_from_file($adapter, $sqlfile, $host, $username, $passw
398398
}
399399
return true;
400400
}
401-
401+
402402
/** Function to run a MySQL script */
403403
static function run_mysql_from_file($sqlfile, $host, $username, $password, $dbname, $port)
404404
{

tests/DatabaseSetup.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21+
/** Get database types */
2122
function getSqlDbTypes($testConfigDir)
2223
{
2324
// setup testing for whichever db config testing files exist
@@ -38,6 +39,7 @@ function getSqlDbTypes($testConfigDir)
3839
return $dbTypes;
3940
}
4041

42+
/** Load database adapter */
4143
function loadDbAdapter($testConfigDir, $dbType)
4244
{
4345
// create the lockfile for this dbType
@@ -63,7 +65,7 @@ function loadDbAdapter($testConfigDir, $dbType)
6365
'username' => $configDatabase->database->params->username,
6466
'password' => $configDatabase->database->params->password,
6567
'dbname' => $configDatabase->database->params->dbname,
66-
'port' =>$configDatabase->database->params->port,));
68+
'port' => $configDatabase->database->params->port));
6769
if($configDatabase->database->profiler == '1')
6870
{
6971
$db->getProfiler()->setEnabled(true);
@@ -79,6 +81,7 @@ function loadDbAdapter($testConfigDir, $dbType)
7981
}
8082
}
8183

84+
/** Drop database tables */
8285
function dropTables($db, $dbType)
8386
{
8487
$tables = $db->listTables();
@@ -96,10 +99,11 @@ function dropTables($db, $dbType)
9699
}
97100
}
98101

102+
/** Install and upgrade core */
99103
function installCore($db, $dbType, $utilityComponent)
100104
{
101105
require_once BASE_PATH.'/core/controllers/components/UpgradeComponent.php';
102-
$upgradeComponent=new UpgradeComponent();
106+
$upgradeComponent = new UpgradeComponent();
103107
$upgradeComponent->dir = BASE_PATH.'/core/database/'.$dbType;
104108
$upgradeComponent->init = true;
105109

@@ -131,7 +135,7 @@ function installCore($db, $dbType, $utilityComponent)
131135
$upgradeComponent->upgrade(str_replace('.sql', '', basename($sqlFile)), true /* true for testing */);
132136
}
133137

134-
// want to create a default assetstore that is separate from application's
138+
/** Create default assetstore */
135139
function createDefaultAssetstore()
136140
{
137141
Zend_Registry::set('models', array());
@@ -164,25 +168,24 @@ function createDefaultAssetstore()
164168
$assetstore->save($assetstoreDao);
165169
}
166170

167-
// install and perform upgrades on modules
168-
//
169-
// What to do about module config files, these should be copied into
170-
// core/configs when a module is installed, but we can't do that
171-
// as there are already module files there, and we may not want
172-
// all the module files
173-
// we could copy the existing ones somewhere, then copy them back at the end
174-
// but I don't like that idea
175-
// for now do nothing
171+
/** Install and upgrade modules */
176172
function installModules($utilityComponent)
177173
{
174+
// What to do about module config files, these should be copied into
175+
// core/configs when a module is installed, but we can't do that
176+
// as there are already module files there, and we may not want
177+
// all the module files
178+
// we could copy the existing ones somewhere, then copy them back at the end
179+
// but I don't like that idea
180+
// for now do nothing
178181
$modules = $utilityComponent->getAllModules();
179182
foreach($modules as $moduleName => $module)
180183
{
181184
$utilityComponent->installModule($moduleName);
182185
}
183186
}
184187

185-
// cleanup the lock file
188+
/** Release lock file */
186189
function releaseLock($dbType)
187190
{
188191
if(file_exists(BASE_PATH.'/tests/configs/lock.'.$dbType.'.ini'))

tests/Utf8tools.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class Utf8tools
2929
* return true if the string is UTF8 encoded.
3030
*/
3131
protected function isUtf8($str)
32-
{
33-
$len = strlen($str);
32+
{
33+
$len = strlen($str);
3434
for($i = 0; $i < $len; $i++)
35-
{
36-
$c = ord($str[$i]);
35+
{
36+
$c = ord($str[$i]);
3737
if($c > 128)
38-
{
38+
{
3939
if(($c > 247))
4040
{
4141
return false;
@@ -61,19 +61,19 @@ protected function isUtf8($str)
6161
return false;
6262
}
6363
while($bytes > 1)
64-
{
65-
$i++;
66-
$b = ord($str[$i]);
64+
{
65+
$i++;
66+
$b = ord($str[$i]);
6767
if($b < 128 || $b > 191)
6868
{
6969
return false;
7070
}
71-
$bytes--;
72-
}
73-
}
74-
}
75-
return true;
76-
} // end of check_utf8
71+
$bytes--;
72+
}
73+
}
74+
}
75+
return true;
76+
}
7777

7878
/**
7979
* gets a list of all files rooted at the src, excluding
@@ -144,7 +144,7 @@ public function listNonUtf8Files($srcDir, $createUtf8Version = false)
144144
$filecontents = file_get_contents($file);
145145
if(!$this->isUtf8($filecontents))
146146
{
147-
echo "ERROR: non-utf8 characters found in $file \n";
147+
echo "ERROR: non-utf8 characters found in ".$file."\n";
148148
if($createUtf8Version)
149149
{
150150
$utf8Version = mb_convert_encoding($filecontents, 'UTF-8');

tests/bootstrap.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
require_once dirname(__FILE__).'/../library/Zend/Loader/Autoloader.php';
3535

36-
# Zend_Loader::registerAutoload();
3736
$loader = Zend_Loader_Autoloader::getInstance();
3837
$loader->setFallbackAutoloader(true);
3938
$loader->suppressNotFoundWarnings(false);
@@ -78,7 +77,7 @@
7877
'username' => $configDatabase->database->params->username,
7978
'password' => $configDatabase->database->params->password,
8079
'dbname' => $configDatabase->database->params->dbname,
81-
'port' =>$configDatabase->database->params->port,
80+
'port' => $configDatabase->database->params->port,
8281
)
8382
);
8483
if($configDatabase->database->profiler == '1')
@@ -96,7 +95,7 @@
9695
Zend_Registry::set('configDatabase', $configDatabase);
9796

9897
require_once BASE_PATH.'/core/controllers/components/UpgradeComponent.php';
99-
$upgradeComponent=new UpgradeComponent();
98+
$upgradeComponent = new UpgradeComponent();
10099
$db = Zend_Registry::get('dbAdapter');
101100
$dbtype = Zend_Registry::get('configDatabase')->database->adapter;
102101

@@ -106,22 +105,22 @@
106105
{
107106
if(Zend_Registry::get('configDatabase')->database->adapter == 'PDO_MYSQL')
108107
{
109-
$type='mysql';
108+
$type = 'mysql';
110109
}
111110
else
112111
{
113-
$type='pgsql';
112+
$type = 'pgsql';
114113
}
115-
$MyDirectory = opendir(BASE_PATH."/core/database/{$type}");
114+
$MyDirectory = opendir(BASE_PATH."/core/database/".$type);
116115
while($Entry = @readdir($MyDirectory))
117116
{
118117
if(strpos($Entry, '.sql') != false)
119118
{
120-
$sqlFile=BASE_PATH."/core/database/{$type}/".$Entry;
119+
$sqlFile = BASE_PATH."/core/database/".$type."/".$Entry;
121120
}
122121
}
123122

124-
$version=str_replace('.sql', '', basename($sqlFile));
123+
$version = str_replace('.sql', '', basename($sqlFile));
125124
}
126125
$upgradeComponent->upgrade($version, true);
127126

tests/library/MIDASStyleChecker.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
exit;
4040
}
4141

42-
$files = _getMatchingFilesRecursive($src);
42+
$files = getMatchingFilesRecursive($src);
4343

4444
foreach($files as $file)
4545
{
@@ -51,14 +51,15 @@
5151
$i++;
5252
if(preg_match('/ [\n\r]*$/', $line))
5353
{
54-
echo "ERROR: Trailing whitespace: $file ($i)\n";
54+
echo "ERROR: Trailing whitespace: ".$file." (".$i.")\n";
5555
}
5656
}
5757

5858
fclose($fh);
5959
}
6060

61-
function _getMatchingFilesRecursive($src, $dir = '')
61+
/** Recursively get matching files */
62+
function getMatchingFilesRecursive($src, $dir = '')
6263
{
6364
$files = array();
6465
if(!file_exists($src))
@@ -86,7 +87,7 @@ function _getMatchingFilesRecursive($src, $dir = '')
8687
$relPath = substr($fullPath, strlen($src) - strlen($dir) + 1);
8788
if(is_dir($src.'/'.$file))
8889
{
89-
$files = array_merge($files, _getMatchingFilesRecursive($src.'/'.$file, $dir.'/'.$file));
90+
$files = array_merge($files, getMatchingFilesRecursive($src.'/'.$file, $dir.'/'.$file));
9091
}
9192
else
9293
{

tests/library/PhpCheckstyle/config/default.cfg.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
<exception value="ldap_bind"/>
195195
<exception value="mkdir"/>
196196
<exception value="rename"/>
197+
<exception value="readdir"/>
197198
</test>
198199

199200
<!-- Check for encapsed variables inside a String ("$a") -->

0 commit comments

Comments
 (0)