mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 05:09:06 +02:00
BUG Prevent fatal errors during test failure halt tests
This commit is contained in:
parent
627fbf9051
commit
3317d34276
@ -5,6 +5,7 @@ namespace SilverStripe\Filesystem\Flysystem;
|
|||||||
use Config;
|
use Config;
|
||||||
use Generator;
|
use Generator;
|
||||||
use Injector;
|
use Injector;
|
||||||
|
use LogicException;
|
||||||
use Session;
|
use Session;
|
||||||
use Flushable;
|
use Flushable;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
@ -98,7 +99,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
|||||||
*/
|
*/
|
||||||
public function setPublicFilesystem(Filesystem $filesystem) {
|
public function setPublicFilesystem(Filesystem $filesystem) {
|
||||||
if(!$filesystem->getAdapter() instanceof PublicAdapter) {
|
if(!$filesystem->getAdapter() instanceof PublicAdapter) {
|
||||||
throw new \InvalidArgumentException("Configured adapter must implement PublicAdapter");
|
throw new InvalidArgumentException("Configured adapter must implement PublicAdapter");
|
||||||
}
|
}
|
||||||
$this->publicFilesystem = $filesystem;
|
$this->publicFilesystem = $filesystem;
|
||||||
return $this;
|
return $this;
|
||||||
@ -108,8 +109,12 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
|||||||
* Get the currently assigned flysystem backend
|
* Get the currently assigned flysystem backend
|
||||||
*
|
*
|
||||||
* @return Filesystem
|
* @return Filesystem
|
||||||
|
* @throws LogicException
|
||||||
*/
|
*/
|
||||||
public function getPublicFilesystem() {
|
public function getPublicFilesystem() {
|
||||||
|
if(!$this->publicFilesystem) {
|
||||||
|
throw new LogicException("Filesystem misconfiguration error");
|
||||||
|
}
|
||||||
return $this->publicFilesystem;
|
return $this->publicFilesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +126,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
|||||||
*/
|
*/
|
||||||
public function setProtectedFilesystem(Filesystem $filesystem) {
|
public function setProtectedFilesystem(Filesystem $filesystem) {
|
||||||
if(!$filesystem->getAdapter() instanceof ProtectedAdapter) {
|
if(!$filesystem->getAdapter() instanceof ProtectedAdapter) {
|
||||||
throw new \InvalidArgumentException("Configured adapter must implement ProtectedAdapter");
|
throw new InvalidArgumentException("Configured adapter must implement ProtectedAdapter");
|
||||||
}
|
}
|
||||||
$this->protectedFilesystem = $filesystem;
|
$this->protectedFilesystem = $filesystem;
|
||||||
return $this;
|
return $this;
|
||||||
@ -133,6 +138,9 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
|||||||
* @return Filesystem
|
* @return Filesystem
|
||||||
*/
|
*/
|
||||||
public function getProtectedFilesystem() {
|
public function getProtectedFilesystem() {
|
||||||
|
if(!$this->protectedFilesystem) {
|
||||||
|
throw new Exception("Filesystem misconfiguration error");
|
||||||
|
}
|
||||||
return $this->protectedFilesystem;
|
return $this->protectedFilesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +632,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
|||||||
switch($conflictResolution) {
|
switch($conflictResolution) {
|
||||||
// Throw tantrum
|
// Throw tantrum
|
||||||
case static::CONFLICT_EXCEPTION: {
|
case static::CONFLICT_EXCEPTION: {
|
||||||
throw new \InvalidArgumentException("File already exists at path {$fileID}");
|
throw new InvalidArgumentException("File already exists at path {$fileID}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename
|
// Rename
|
||||||
@ -635,7 +643,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException("File could not be renamed with path {$fileID}");
|
throw new InvalidArgumentException("File could not be renamed with path {$fileID}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use existing file
|
// Use existing file
|
||||||
|
@ -38,6 +38,9 @@ class FlysystemGeneratedAssetHandler implements GeneratedAssetHandler {
|
|||||||
* @return Filesystem
|
* @return Filesystem
|
||||||
*/
|
*/
|
||||||
public function getFilesystem() {
|
public function getFilesystem() {
|
||||||
|
if(!$this->assetStore) {
|
||||||
|
throw new Exception("Filesystem misconfiguration error");
|
||||||
|
}
|
||||||
return $this->assetStore;
|
return $this->assetStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user