Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent capilization of io_saveFile and psr-2 formatting #2992

Merged
merged 2 commits into from Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions inc/Cache/Cache.php
Expand Up @@ -78,9 +78,13 @@ public function useCache($depends = array())
$this->depends = $depends;
$this->addDependencies();

if ($this->_event) {
return $this->stats(Event::createAndTrigger(
$this->_event, $this, array($this, 'makeDefaultCacheDecision'))
if ($this->getEvent()) {
return $this->stats(
Event::createAndTrigger(
$this->getEvent(),
$this,
array($this, 'makeDefaultCacheDecision')
)
);
}

Expand All @@ -105,7 +109,6 @@ public function useCache($depends = array())
*/
public function makeDefaultCacheDecision()
{

if ($this->_nocache) {
return false;
} // caching turned off
Expand Down Expand Up @@ -170,7 +173,7 @@ public function storeCache($data)
return false;
}

return io_savefile($this->cache, $data);
return io_saveFile($this->cache, $data);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion inc/Cache/CacheInstructions.php
Expand Up @@ -41,6 +41,6 @@ public function storeCache($instructions)
return false;
}

return io_savefile($this->cache, serialize($instructions));
return io_saveFile($this->cache, serialize($instructions));
}
}
38 changes: 23 additions & 15 deletions lib/plugins/usermanager/_test/csv_import.test.php
Expand Up @@ -14,13 +14,14 @@
*
* At present, users imported in individual tests remain in the user list for subsequent tests
*/
class plugin_usermanager_csv_import_test extends DokuWikiTest {

class plugin_usermanager_csv_import_test extends DokuWikiTest
{
private $old_files;
protected $usermanager;
protected $importfile;

function setUp() {
public function setUp()
{
$this->importfile = tempnam(TMP_DIR, 'csv');

$this->old_files = $_FILES;
Expand All @@ -38,16 +39,18 @@ function setUp() {
parent::setUp();
}

function tearDown() {
public function tearDown()
{
$_FILES = $this->old_files;
parent::tearDown();
}

function doImportTest($importCsv, $expectedResult, $expectedNewUsers, $expectedFailures) {
public function doImportTest($importCsv, $expectedResult, $expectedNewUsers, $expectedFailures)
{
global $auth;
$before_users = $auth->retrieveUsers();

io_savefile($this->importfile, $importCsv);
io_saveFile($this->importfile, $importCsv);
$result = $this->usermanager->tryImport();

$after_users = $auth->retrieveUsers();
Expand All @@ -69,7 +72,8 @@ function doImportTest($importCsv, $expectedResult, $expectedNewUsers, $expectedF
$this->assertEquals($expectedFailures, $this->usermanager->getImportFailures()); // failures as expected
}

function test_cantImport(){
public function test_cantImport()
{
global $auth;
$oldauth = $auth;

Expand All @@ -85,7 +89,8 @@ function test_cantImport(){
$auth = $oldauth;
}

function test_import() {
public function test_import()
{
$csv = 'User,"Real Name",Email,Groups
importuser,"Ford Prefect",ford@example.com,user
';
Expand All @@ -100,7 +105,8 @@ function test_import() {
$this->doImportTest($csv, true, $expected, array());
}

function test_importExisting() {
public function test_importExisting()
{
$csv = 'User,"Real Name",Email,Groups
importuser,"Ford Prefect",ford@example.com,user
';
Expand All @@ -120,7 +126,8 @@ function test_importExisting() {
$this->doImportTest($csv, true, array(), $failures);
}

function test_importUtf8() {
public function test_importUtf8()
{
$csv = 'User,"Real Name",Email,Groups
importutf8,"Førd Prefect",ford@example.com,user
';
Expand All @@ -138,7 +145,8 @@ function test_importUtf8() {
/**
* utf8: u+00F8 (ø) <=> 0xF8 :iso-8859-1
*/
function test_importIso8859() {
public function test_importIso8859()
{
$csv = 'User,"Real Name",Email,Groups
importiso8859,"F'.chr(0xF8).'rd Prefect",ford@example.com,user
';
Expand All @@ -153,14 +161,16 @@ function test_importIso8859() {
$this->doImportTest($csv, true, $expected, array());
}

private function stripPasswords($array){
private function stripPasswords($array)
{
foreach ($array as $user => $data) {
unset($array[$user]['pass']);
}
return $array;
}

private function countPasswords($array){
private function countPasswords($array)
{
$count = 0;
foreach ($array as $user => $data) {
if (!empty($data['pass'])) {
Expand All @@ -169,6 +179,4 @@ private function countPasswords($array){
}
return $count;
}

}