aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
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
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')
-rw-r--r--tests/ApplicationUtilsTest.php69
-rw-r--r--tests/LinkDBTest.php5
2 files changed, 72 insertions, 2 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}
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index 451f1d6f..8929713d 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6require_once 'application/Cache.php'; 6require_once 'application/Cache.php';
7require_once 'application/FileUtils.php';
7require_once 'application/LinkDB.php'; 8require_once 'application/LinkDB.php';
8require_once 'application/Utils.php'; 9require_once 'application/Utils.php';
9require_once 'tests/utils/ReferenceLinkDB.php'; 10require_once 'tests/utils/ReferenceLinkDB.php';
@@ -87,8 +88,8 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
87 /** 88 /**
88 * Attempt to instantiate a LinkDB whereas the datastore is not writable 89 * Attempt to instantiate a LinkDB whereas the datastore is not writable
89 * 90 *
90 * @expectedException PHPUnit_Framework_Error_Warning 91 * @expectedException IOException
91 * @expectedExceptionMessageRegExp /failed to open stream: No such file or directory/ 92 * @expectedExceptionMessageRegExp /Error accessing null/
92 */ 93 */
93 public function testConstructDatastoreNotWriteable() 94 public function testConstructDatastoreNotWriteable()
94 { 95 {