Minor improvements regarding (coding style, unit tests, etc.)

This commit is contained in:
ArthurHoaro 2017-01-03 11:42:21 +01:00
parent adc4aee80f
commit a0df06517b
20 changed files with 92 additions and 28 deletions

View file

@ -331,4 +331,48 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
ApplicationUtils::checkResourcePermissions($conf)
);
}
/**
* Test getThemes() with existing theme directories.
*/
public function testGetThemes()
{
$themes = ['theme1', 'default', 'Bl1p_- bL0p'];
foreach ($themes as $theme) {
mkdir('sandbox/tpl/'. $theme, 0777, true);
}
// include a file which should be ignored
touch('sandbox/tpl/supertheme');
$res = ApplicationUtils::getThemes('sandbox/tpl/');
foreach ($res as $theme) {
$this->assertTrue(in_array($theme, $themes));
}
$this->assertFalse(in_array('supertheme', $res));
foreach ($themes as $theme) {
rmdir('sandbox/tpl/'. $theme);
}
unlink('sandbox/tpl/supertheme');
rmdir('sandbox/tpl');
}
/**
* Test getThemes() without any theme dir.
*/
public function testGetThemesEmpty()
{
mkdir('sandbox/tpl/', 0777, true);
$this->assertEquals([], ApplicationUtils::getThemes('sandbox/tpl/'));
rmdir('sandbox/tpl/');
}
/**
* Test getThemes() with an invalid path.
*/
public function testGetThemesInvalid()
{
$this->assertEquals([], ApplicationUtils::getThemes('nope'));
}
}

View file

@ -2,6 +2,7 @@
require_once 'application/config/ConfigManager.php';
require_once 'tests/Updater/DummyUpdater.php';
require_once 'inc/rain.tpl.class.php';
/**
* Class UpdaterTest.

View file

@ -24,7 +24,8 @@
},
"resource": {
"datastore": "tests\/utils\/config\/datastore.php",
"data_dir": "tests\/utils\/config"
"data_dir": "tests\/utils\/config",
"raintpl_tpl": "tpl/"
},
"plugins": {
"WALLABAG_VERSION": 1