aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ApplicationUtilsTest.php
diff options
context:
space:
mode:
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}