fix tests

This commit is contained in:
Dennis Eichhorn 2023-09-29 04:09:40 +00:00
parent fa68acc4be
commit d9167a9d06
2 changed files with 12 additions and 7 deletions

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace phpOMS\System\File;
use phpOMS\Autoloader;
/**
* Filesystem class.
*
@ -71,15 +73,18 @@ final class Storage
throw new \Exception('Invalid type');
}
} else {
$stg = $env;
$env = \ucfirst(\strtolower($env));
/** @var StorageAbstract $env */
$env = __NAMESPACE__ . '\\' . $env . '\\' . $env . 'Storage';
$stg = \ucfirst(\strtolower($env));
$stg = __NAMESPACE__ . '\\' . $stg . '\\' . $stg . 'Storage';
if (!Autoloader::exists($stg)) {
throw new \Exception('Invalid type');
}
/** @var StorageAbstract $stg */
/** @var StorageAbstract $instance */
$instance = new $env();
$instance = new $stg();
self::$registered[$stg] = $instance;
self::$registered[$env] = $instance;
}
return $instance;

View File

@ -76,7 +76,7 @@ final class StorageTest extends \PHPUnit\Framework\TestCase
*/
public function testInvalidStorage() : void
{
$this->expectException(\Error::class);
$this->expectException(\Exception::class);
self::assertInstanceOf('\phpOMS\System\File\Local\LocalStorage', Storage::env('invalid'));
}