diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-21 13:12:15 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-21 15:06:47 +0200 |
commit | 0cf76ccb4736473a958d9fd36ed914e2d25d594a (patch) | |
tree | 0bb11821bc45ad2a7c2b965137a901ae5546455a /tests/ApplicationUtilsTest.php | |
parent | d8030c8155ee4c20573848b2444f6df0b65d1662 (diff) | |
download | Shaarli-0cf76ccb4736473a958d9fd36ed914e2d25d594a.tar.gz Shaarli-0cf76ccb4736473a958d9fd36ed914e2d25d594a.tar.zst Shaarli-0cf76ccb4736473a958d9fd36ed914e2d25d594a.zip |
Feature: add a Server administration page
It contains mostly read only information about the current Shaarli instance,
PHP version, extensions, file and folder permissions, etc.
Also action buttons to clear the cache or sync thumbnails.
Part of the content of this page is also displayed on the install page,
to check server requirement before installing Shaarli config file.
Fixes #40
Fixes #185
Diffstat (limited to 'tests/ApplicationUtilsTest.php')
-rw-r--r-- | tests/ApplicationUtilsTest.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index a232b351..ac46cbf1 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php | |||
@@ -340,6 +340,35 @@ class ApplicationUtilsTest extends \Shaarli\TestCase | |||
340 | } | 340 | } |
341 | 341 | ||
342 | /** | 342 | /** |
343 | * Checks resource permissions in minimal mode. | ||
344 | */ | ||
345 | public function testCheckCurrentResourcePermissionsErrorsMinimalMode(): void | ||
346 | { | ||
347 | $conf = new ConfigManager(''); | ||
348 | $conf->set('resource.thumbnails_cache', 'null/cache'); | ||
349 | $conf->set('resource.config', 'null/data/config.php'); | ||
350 | $conf->set('resource.data_dir', 'null/data'); | ||
351 | $conf->set('resource.datastore', 'null/data/store.php'); | ||
352 | $conf->set('resource.ban_file', 'null/data/ipbans.php'); | ||
353 | $conf->set('resource.log', 'null/data/log.txt'); | ||
354 | $conf->set('resource.page_cache', 'null/pagecache'); | ||
355 | $conf->set('resource.raintpl_tmp', 'null/tmp'); | ||
356 | $conf->set('resource.raintpl_tpl', 'null/tpl'); | ||
357 | $conf->set('resource.raintpl_theme', 'null/tpl/default'); | ||
358 | $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt'); | ||
359 | |||
360 | static::assertSame( | ||
361 | [ | ||
362 | '"null/tpl" directory is not readable', | ||
363 | '"null/tpl/default" directory is not readable', | ||
364 | '"null/tmp" directory is not readable', | ||
365 | '"null/tmp" directory is not writable' | ||
366 | ], | ||
367 | ApplicationUtils::checkResourcePermissions($conf, true) | ||
368 | ); | ||
369 | } | ||
370 | |||
371 | /** | ||
343 | * Check update with 'dev' as curent version (master branch). | 372 | * Check update with 'dev' as curent version (master branch). |
344 | * It should always return false. | 373 | * It should always return false. |
345 | */ | 374 | */ |
@@ -349,4 +378,37 @@ class ApplicationUtilsTest extends \Shaarli\TestCase | |||
349 | ApplicationUtils::checkUpdate('dev', self::$testUpdateFile, 100, true, true) | 378 | ApplicationUtils::checkUpdate('dev', self::$testUpdateFile, 100, true, true) |
350 | ); | 379 | ); |
351 | } | 380 | } |
381 | |||
382 | /** | ||
383 | * Basic test of getPhpExtensionsRequirement() | ||
384 | */ | ||
385 | public function testGetPhpExtensionsRequirementSimple(): void | ||
386 | { | ||
387 | static::assertCount(8, ApplicationUtils::getPhpExtensionsRequirement()); | ||
388 | static::assertSame([ | ||
389 | 'name' => 'json', | ||
390 | 'required' => true, | ||
391 | 'desc' => 'Configuration parsing', | ||
392 | 'loaded' => true, | ||
393 | ], ApplicationUtils::getPhpExtensionsRequirement()[0]); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Test getPhpEol with a known version: 7.4 -> 2022 | ||
398 | */ | ||
399 | public function testGetKnownPhpEol(): void | ||
400 | { | ||
401 | static::assertSame('2022-11-28', ApplicationUtils::getPhpEol('7.4.7')); | ||
402 | } | ||
403 | |||
404 | /** | ||
405 | * Test getPhpEol with an unknown version: 7.4 -> 2022 | ||
406 | */ | ||
407 | public function testGetUnknownPhpEol(): void | ||
408 | { | ||
409 | static::assertSame( | ||
410 | (((int) (new \DateTime())->format('Y')) + 2) . (new \DateTime())->format('-m-d'), | ||
411 | ApplicationUtils::getPhpEol('7.51.34') | ||
412 | ); | ||
413 | } | ||
352 | } | 414 | } |