aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ApplicationUtilsTest.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-11-24 01:26:30 +0100
committerVirtualTam <virtualtam@flibidi.net>2015-11-24 01:26:30 +0100
commit0def004963c62ff1edfce16272a87ba9f0c87e16 (patch)
treef743e785edf708454ab53efa13f38e35f10447e6 /tests/ApplicationUtilsTest.php
parentc580024cfbe5f0d290b09157b9665d1b4131d7f4 (diff)
parent2e28269baed195d58bbe169841eed176b171db76 (diff)
downloadShaarli-0def004963c62ff1edfce16272a87ba9f0c87e16.tar.gz
Shaarli-0def004963c62ff1edfce16272a87ba9f0c87e16.tar.zst
Shaarli-0def004963c62ff1edfce16272a87ba9f0c87e16.zip
Merge pull request #375 from virtualtam/utils/permissions
tools: check file/directory permissions for Shaarli resources
Diffstat (limited to 'tests/ApplicationUtilsTest.php')
-rw-r--r--tests/ApplicationUtilsTest.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php
new file mode 100644
index 00000000..9a99c6c6
--- /dev/null
+++ b/tests/ApplicationUtilsTest.php
@@ -0,0 +1,69 @@
1<?php
2/**
3 * ApplicationUtils' tests
4 */
5
6require_once 'application/ApplicationUtils.php';
7
8
9/**
10 * Unitary tests for Shaarli utilities
11 */
12class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
13{
14 /**
15 * Checks resource permissions for the current Shaarli installation
16 */
17 public function testCheckCurrentResourcePermissions()
18 {
19 $config = array(
20 'CACHEDIR' => 'cache',
21 'CONFIG_FILE' => 'data/config.php',
22 'DATADIR' => 'data',
23 'DATASTORE' => 'data/datastore.php',
24 'IPBANS_FILENAME' => 'data/ipbans.php',
25 'LOG_FILE' => 'data/log.txt',
26 'PAGECACHE' => 'pagecache',
27 'RAINTPL_TMP' => 'tmp',
28 'RAINTPL_TPL' => 'tpl',
29 'UPDATECHECK_FILENAME' => 'data/lastupdatecheck.txt'
30 );
31 $this->assertEquals(
32 array(),
33 ApplicationUtils::checkResourcePermissions($config)
34 );
35 }
36
37 /**
38 * Checks resource permissions for a non-existent Shaarli installation
39 */
40 public function testCheckCurrentResourcePermissionsErrors()
41 {
42 $config = array(
43 'CACHEDIR' => 'null/cache',
44 'CONFIG_FILE' => 'null/data/config.php',
45 'DATADIR' => 'null/data',
46 'DATASTORE' => 'null/data/store.php',
47 'IPBANS_FILENAME' => 'null/data/ipbans.php',
48 'LOG_FILE' => 'null/data/log.txt',
49 'PAGECACHE' => 'null/pagecache',
50 'RAINTPL_TMP' => 'null/tmp',
51 'RAINTPL_TPL' => 'null/tpl',
52 'UPDATECHECK_FILENAME' => 'null/data/lastupdatecheck.txt'
53 );
54 $this->assertEquals(
55 array(
56 '"null/tpl" directory is not readable',
57 '"null/cache" directory is not readable',
58 '"null/cache" directory is not writable',
59 '"null/data" directory is not readable',
60 '"null/data" directory is not writable',
61 '"null/pagecache" directory is not readable',
62 '"null/pagecache" directory is not writable',
63 '"null/tmp" directory is not readable',
64 '"null/tmp" directory is not writable'
65 ),
66 ApplicationUtils::checkResourcePermissions($config)
67 );
68 }
69}