3 * ApplicationUtils' tests
6 require_once 'application/ApplicationUtils.php';
10 * Unitary tests for Shaarli utilities
12 class ApplicationUtilsTest
extends PHPUnit_Framework_TestCase
15 * Check supported PHP versions
17 public function testCheckSupportedPHPVersion()
20 ApplicationUtils
::checkPHPVersion($minVersion, '5.4.32');
21 ApplicationUtils
::checkPHPVersion($minVersion, '5.5');
22 ApplicationUtils
::checkPHPVersion($minVersion, '5.6.10');
26 * Check a unsupported PHP version
27 * @expectedException Exception
28 * @expectedExceptionMessageRegExp /Your PHP version is obsolete/
30 public function testCheckSupportedPHPVersion51()
32 ApplicationUtils
::checkPHPVersion('5.3', '5.1.0');
36 * Check another unsupported PHP version
37 * @expectedException Exception
38 * @expectedExceptionMessageRegExp /Your PHP version is obsolete/
40 public function testCheckSupportedPHPVersion52()
42 ApplicationUtils
::checkPHPVersion('5.3', '5.2');
46 * Checks resource permissions for the current Shaarli installation
48 public function testCheckCurrentResourcePermissions()
51 'CACHEDIR' => 'cache',
52 'CONFIG_FILE' => 'data/config.php',
54 'DATASTORE' => 'data/datastore.php',
55 'IPBANS_FILENAME' => 'data/ipbans.php',
56 'LOG_FILE' => 'data/log.txt',
57 'PAGECACHE' => 'pagecache',
58 'RAINTPL_TMP' => 'tmp',
59 'RAINTPL_TPL' => 'tpl',
60 'UPDATECHECK_FILENAME' => 'data/lastupdatecheck.txt'
64 ApplicationUtils
::checkResourcePermissions($config)
69 * Checks resource permissions for a non-existent Shaarli installation
71 public function testCheckCurrentResourcePermissionsErrors()
74 'CACHEDIR' => 'null/cache',
75 'CONFIG_FILE' => 'null/data/config.php',
76 'DATADIR' => 'null/data',
77 'DATASTORE' => 'null/data/store.php',
78 'IPBANS_FILENAME' => 'null/data/ipbans.php',
79 'LOG_FILE' => 'null/data/log.txt',
80 'PAGECACHE' => 'null/pagecache',
81 'RAINTPL_TMP' => 'null/tmp',
82 'RAINTPL_TPL' => 'null/tpl',
83 'UPDATECHECK_FILENAME' => 'null/data/lastupdatecheck.txt'
87 '"null/tpl" directory is not readable',
88 '"null/cache" directory is not readable',
89 '"null/cache" directory is not writable',
90 '"null/data" directory is not readable',
91 '"null/data" directory is not writable',
92 '"null/pagecache" directory is not readable',
93 '"null/pagecache" directory is not writable',
94 '"null/tmp" directory is not readable',
95 '"null/tmp" directory is not writable'
97 ApplicationUtils
::checkResourcePermissions($config)