namespacing: \Shaarli\Exceptions\IOException
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
parent
bdc5152d48
commit
f3d2f25794
11 changed files with 24 additions and 10 deletions
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Exceptions\IOException;
|
||||
|
||||
require_once 'exceptions/IOException.php';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Exceptions\IOException;
|
||||
|
||||
/**
|
||||
* Data storage for links.
|
||||
*
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
use Shaarli\Config\ConfigJson;
|
||||
use Shaarli\Config\ConfigPhp;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Exceptions\IOException;
|
||||
use Shaarli\Thumbnailer;
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,7 +47,7 @@ public function write($filepath, $conf)
|
|||
$print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
|
||||
$data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix();
|
||||
if (!file_put_contents($filepath, $data)) {
|
||||
throw new \IOException(
|
||||
throw new \Shaarli\Exceptions\IOException(
|
||||
$filepath,
|
||||
t('Shaarli could not create the config file. '.
|
||||
'Please make sure Shaarli has the right to write in the folder is it installed in.')
|
||||
|
|
|
@ -207,7 +207,7 @@ public function exists($setting)
|
|||
*
|
||||
* @throws MissingFieldConfigException: a mandatory field has not been provided in $conf.
|
||||
* @throws UnauthorizedConfigException: user is not authorize to change configuration.
|
||||
* @throws \IOException: an error occurred while writing the new config file.
|
||||
* @throws \Shaarli\Exceptions\IOException: an error occurred while writing the new config file.
|
||||
*/
|
||||
public function write($isLoggedIn)
|
||||
{
|
||||
|
|
|
@ -124,7 +124,7 @@ public function write($filepath, $conf)
|
|||
if (!file_put_contents($filepath, $configStr)
|
||||
|| strcmp(file_get_contents($filepath), $configStr) != 0
|
||||
) {
|
||||
throw new \IOException(
|
||||
throw new \Shaarli\Exceptions\IOException(
|
||||
$filepath,
|
||||
t('Shaarli could not create the config file. '.
|
||||
'Please make sure Shaarli has the right to write in the folder is it installed in.')
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
namespace Shaarli\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Exception class thrown when a filesystem access failure happens
|
||||
|
@ -17,6 +20,6 @@ public function __construct($path, $message = '')
|
|||
{
|
||||
$this->path = $path;
|
||||
$this->message = empty($message) ? t('Error accessing') : $message;
|
||||
$this->message .= ' "' . $this->path .'"';
|
||||
$this->message .= ' "' . $this->path . '"';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
"Shaarli\\Api\\Exceptions\\": "application/api/exceptions",
|
||||
"Shaarli\\Config\\": "application/config/",
|
||||
"Shaarli\\Config\\Exception\\": "application/config/exception",
|
||||
"Shaarli\\Exceptions\\": "application/exceptions",
|
||||
"Shaarli\\Security\\": "application/security"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Exceptions\IOException;
|
||||
|
||||
require_once 'application/FileUtils.php';
|
||||
|
||||
/**
|
||||
|
@ -48,7 +50,7 @@ public function testSimpleWriteRead()
|
|||
/**
|
||||
* File not writable: raise an exception.
|
||||
*
|
||||
* @expectedException IOException
|
||||
* @expectedException Shaarli\Exceptions\IOException
|
||||
* @expectedExceptionMessage Error accessing "sandbox/flat.db"
|
||||
*/
|
||||
public function testWriteWithoutPermission()
|
||||
|
@ -61,7 +63,7 @@ public function testWriteWithoutPermission()
|
|||
/**
|
||||
* Folder non existent: raise an exception.
|
||||
*
|
||||
* @expectedException IOException
|
||||
* @expectedException Shaarli\Exceptions\IOException
|
||||
* @expectedExceptionMessage Error accessing "nopefolder"
|
||||
*/
|
||||
public function testWriteFolderDoesNotExist()
|
||||
|
@ -72,7 +74,7 @@ public function testWriteFolderDoesNotExist()
|
|||
/**
|
||||
* Folder non writable: raise an exception.
|
||||
*
|
||||
* @expectedException IOException
|
||||
* @expectedException Shaarli\Exceptions\IOException
|
||||
* @expectedExceptionMessage Error accessing "sandbox"
|
||||
*/
|
||||
public function testWriteFolderPermission()
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
* Link datastore tests
|
||||
*/
|
||||
|
||||
use Shaarli\Exceptions\IOException;
|
||||
|
||||
require_once 'application/Cache.php';
|
||||
require_once 'application/FileUtils.php';
|
||||
require_once 'application/LinkDB.php';
|
||||
|
@ -100,7 +102,7 @@ public function testConstructLoggedOut()
|
|||
/**
|
||||
* Attempt to instantiate a LinkDB whereas the datastore is not writable
|
||||
*
|
||||
* @expectedException IOException
|
||||
* @expectedException Shaarli\Exceptions\IOException
|
||||
* @expectedExceptionMessageRegExp /Error accessing "null"/
|
||||
*/
|
||||
public function testConstructDatastoreNotWriteable()
|
||||
|
|
|
@ -111,7 +111,7 @@ public function testOverwrite()
|
|||
/**
|
||||
* Write to invalid path.
|
||||
*
|
||||
* @expectedException \IOException
|
||||
* @expectedException \Shaarli\Exceptions\IOException
|
||||
*/
|
||||
public function testWriteInvalidArray()
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ public function testWriteInvalidArray()
|
|||
/**
|
||||
* Write to invalid path.
|
||||
*
|
||||
* @expectedException \IOException
|
||||
* @expectedException \Shaarli\Exceptions\IOException
|
||||
*/
|
||||
public function testWriteInvalidBlank()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue