@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | string $sUri = '', string $sDir = '', string $sType = ''): Bootstrap |
| 90 | 90 | { |
| 91 | 91 | // Don't change the existing assets config. |
| 92 | - if(!$this->xConfigManager->hasAppOption('assets')) |
|
| 92 | + if (!$this->xConfigManager->hasAppOption('assets')) |
|
| 93 | 93 | { |
| 94 | 94 | $this->xConfigManager->asset($bExport, $bMinify, $sUri, $sDir, $sType); |
| 95 | 95 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | // Popping the callbacks makes each of them to be called once. |
| 146 | 146 | $aBootCallbacks = $this->xCallbackManager->popBootCallbacks(); |
| 147 | - foreach($aBootCallbacks as $aBootCallback) |
|
| 147 | + foreach ($aBootCallbacks as $aBootCallback) |
|
| 148 | 148 | { |
| 149 | 149 | call_user_func($aBootCallback); |
| 150 | 150 | } |
@@ -75,22 +75,22 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | return $this->xConfigReader->read($sConfigFile); |
| 77 | 77 | } |
| 78 | - catch(YamlExtension $e) |
|
| 78 | + catch (YamlExtension $e) |
|
| 79 | 79 | { |
| 80 | 80 | $sMessage = $this->xTranslator->trans('errors.yaml.install'); |
| 81 | 81 | throw new SetupException($sMessage); |
| 82 | 82 | } |
| 83 | - catch(FileExtension $e) |
|
| 83 | + catch (FileExtension $e) |
|
| 84 | 84 | { |
| 85 | 85 | $sMessage = $this->xTranslator->trans('errors.file.extension', ['path' => $sConfigFile]); |
| 86 | 86 | throw new SetupException($sMessage); |
| 87 | 87 | } |
| 88 | - catch(FileAccess $e) |
|
| 88 | + catch (FileAccess $e) |
|
| 89 | 89 | { |
| 90 | 90 | $sMessage = $this->xTranslator->trans('errors.file.access', ['path' => $sConfigFile]); |
| 91 | 91 | throw new SetupException($sMessage); |
| 92 | 92 | } |
| 93 | - catch(FileContent $e) |
|
| 93 | + catch (FileContent $e) |
|
| 94 | 94 | { |
| 95 | 95 | $sMessage = $this->xTranslator->trans('errors.file.content', ['path' => $sConfigFile]); |
| 96 | 96 | throw new SetupException($sMessage); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | // Call the config change listeners. |
| 117 | 117 | $this->xEventManager->libConfigChanged($this->xLibConfig, ''); |
| 118 | 118 | } |
| 119 | - catch(DataDepth $e) |
|
| 119 | + catch (DataDepth $e) |
|
| 120 | 120 | { |
| 121 | 121 | $sMessage = $this->xTranslator->trans('errors.data.depth', [ |
| 122 | 122 | 'key' => $e->sPrefix, |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $this->xEventManager->libConfigChanged($this->xLibConfig, ''); |
| 146 | 146 | return $this->xLibConfig->changed(); |
| 147 | 147 | } |
| 148 | - catch(DataDepth $e) |
|
| 148 | + catch (DataDepth $e) |
|
| 149 | 149 | { |
| 150 | 150 | $sMessage = $this->xTranslator->trans('errors.data.depth', [ |
| 151 | 151 | 'key' => $e->sPrefix, |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $this->xEventManager->appConfigChanged($this->xAppConfig, ''); |
| 253 | 253 | return $this->xAppConfig->changed(); |
| 254 | 254 | } |
| 255 | - catch(DataDepth $e) |
|
| 255 | + catch (DataDepth $e) |
|
| 256 | 256 | { |
| 257 | 257 | $sMessage = $this->xTranslator->trans('errors.data.depth', [ |
| 258 | 258 | 'key' => $e->sPrefix, |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | { |
| 315 | 315 | return $this->xConfigSetter->newConfig($aOptions, $sNamePrefix); |
| 316 | 316 | } |
| 317 | - catch(DataDepth $e) |
|
| 317 | + catch (DataDepth $e) |
|
| 318 | 318 | { |
| 319 | 319 | $sMessage = $this->xTranslator->trans('errors.data.depth', [ |
| 320 | 320 | 'key' => $e->sPrefix, |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function globals(bool $bForce = false): void |
| 365 | 365 | { |
| 366 | - if($bForce || $this->getAppOption('helpers.global', true)) |
|
| 366 | + if ($bForce || $this->getAppOption('helpers.global', true)) |
|
| 367 | 367 | { |
| 368 | 368 | require_once dirname(__DIR__, 2) . '/globals.php'; |
| 369 | 369 | } |
@@ -374,15 +374,14 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | public function getExportConfig(): Config |
| 376 | 376 | { |
| 377 | - if($this->xExportConfig !== null) |
|
| 377 | + if ($this->xExportConfig !== null) |
|
| 378 | 378 | { |
| 379 | 379 | return $this->xExportConfig; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | // Copy the assets options in a new config object. |
| 383 | 383 | return $this->xExportConfig = $this->hasAppOption('assets') ? |
| 384 | - $this->xConfigSetter->newConfig($this->getAppOption('assets')) : |
|
| 385 | - // Convert the options in the "lib" section to the same format as in the "app" section. |
|
| 384 | + $this->xConfigSetter->newConfig($this->getAppOption('assets')) : // Convert the options in the "lib" section to the same format as in the "app" section. |
|
| 386 | 385 | $this->xConfigSetter->newConfig([ |
| 387 | 386 | 'js' => $this->getOption('js.app'), |
| 388 | 387 | 'include' => $this->getOption('assets.include'), |
@@ -409,11 +408,11 @@ discard block |
||
| 409 | 408 | 'export' => $bExport, |
| 410 | 409 | 'minify' => $bMinify, |
| 411 | 410 | ]; |
| 412 | - if($sUri !== '') |
|
| 411 | + if ($sUri !== '') |
|
| 413 | 412 | { |
| 414 | 413 | $aJsOptions['uri'] = $sUri; |
| 415 | 414 | } |
| 416 | - if($sDir !== '') |
|
| 415 | + if ($sDir !== '') |
|
| 417 | 416 | { |
| 418 | 417 | $aJsOptions['dir'] = $sDir; |
| 419 | 418 | } |
@@ -24,36 +24,36 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | class Config |
| 26 | 26 | { |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * The constructor |
| 29 | 29 | * |
| 30 | 30 | * @param array $aValues |
| 31 | 31 | * @param bool $bChanged |
| 32 | 32 | */ |
| 33 | - public function __construct(private array $aValues = [], private bool $bChanged = true) |
|
| 34 | - {} |
|
| 33 | +public function __construct(private array $aValues = [], private bool $bChanged = true) |
|
| 34 | +{} |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * Get the config values |
| 38 | 38 | * |
| 39 | 39 | * @return array |
| 40 | 40 | */ |
| 41 | - public function getValues(): array |
|
| 42 | - { |
|
| 43 | - return $this->aValues; |
|
| 44 | - } |
|
| 41 | +public function getValues(): array |
|
| 42 | +{ |
|
| 43 | +return $this->aValues; |
|
| 44 | +} |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * If the values has changed |
| 48 | 48 | * |
| 49 | 49 | * @return bool |
| 50 | 50 | */ |
| 51 | - public function changed(): bool |
|
| 52 | - { |
|
| 53 | - return $this->bChanged; |
|
| 54 | - } |
|
| 51 | +public function changed(): bool |
|
| 52 | +{ |
|
| 53 | +return $this->bChanged; |
|
| 54 | +} |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | +/** |
|
| 57 | 57 | * Get the value of a config option |
| 58 | 58 | * |
| 59 | 59 | * @param string $sName The option name |
@@ -61,47 +61,47 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return mixed |
| 63 | 63 | */ |
| 64 | - public function getOption(string $sName, $xDefault = null) |
|
| 65 | - { |
|
| 66 | - return $sName === '' ? $this->aValues : $this->aValues[$sName] ?? $xDefault; |
|
| 67 | - } |
|
| 64 | +public function getOption(string $sName, $xDefault = null) |
|
| 65 | +{ |
|
| 66 | +return $sName === '' ? $this->aValues : $this->aValues[$sName] ?? $xDefault; |
|
| 67 | +} |
|
| 68 | 68 | |
| 69 | - /** |
|
| 69 | +/** |
|
| 70 | 70 | * Check the presence of a config option |
| 71 | 71 | * |
| 72 | 72 | * @param string $sName The option name |
| 73 | 73 | * |
| 74 | 74 | * @return bool |
| 75 | 75 | */ |
| 76 | - public function hasOption(string $sName): bool |
|
| 77 | - { |
|
| 78 | - return array_key_exists($sName, $this->aValues); |
|
| 79 | - } |
|
| 76 | +public function hasOption(string $sName): bool |
|
| 77 | +{ |
|
| 78 | +return array_key_exists($sName, $this->aValues); |
|
| 79 | +} |
|
| 80 | 80 | |
| 81 | - /** |
|
| 81 | +/** |
|
| 82 | 82 | * Get the names of the options under a given key |
| 83 | 83 | * |
| 84 | 84 | * @param string $sKey The prefix to match |
| 85 | 85 | * |
| 86 | 86 | * @return array |
| 87 | 87 | */ |
| 88 | - public function getOptionNames(string $sKey): array |
|
| 89 | - { |
|
| 90 | - $sKey = trim($sKey, ' .'); |
|
| 91 | - $aKeys = Value::explodeName($sKey); |
|
| 92 | - $aValues = $this->aValues; |
|
| 93 | - foreach($aKeys as $_sKey) |
|
| 94 | - { |
|
| 95 | - $aValues = $aValues[$_sKey] ?? []; |
|
| 96 | - } |
|
| 97 | - if(!Value::containsOptions($aValues)) |
|
| 98 | - { |
|
| 99 | - return []; |
|
| 100 | - } |
|
| 88 | +public function getOptionNames(string $sKey): array |
|
| 89 | +{ |
|
| 90 | +$sKey = trim($sKey, ' .'); |
|
| 91 | +$aKeys = Value::explodeName($sKey); |
|
| 92 | +$aValues = $this->aValues; |
|
| 93 | +foreach($aKeys as $_sKey) |
|
| 94 | +{ |
|
| 95 | +$aValues = $aValues[$_sKey] ?? []; |
|
| 96 | +} |
|
| 97 | +if(!Value::containsOptions($aValues)) |
|
| 98 | +{ |
|
| 99 | +return []; |
|
| 100 | +} |
|
| 101 | 101 | |
| 102 | - // The returned value is an array with short names as keys and full names as values. |
|
| 103 | - $aNames = array_keys($aValues); |
|
| 104 | - $aFullNames = array_map(fn($sName) => "$sKey.$sName", $aNames); |
|
| 105 | - return array_combine($aNames, $aFullNames); |
|
| 106 | - } |
|
| 102 | +// The returned value is an array with short names as keys and full names as values. |
|
| 103 | +$aNames = array_keys($aValues); |
|
| 104 | +$aFullNames = array_map(fn($sName) => "$sKey.$sName", $aNames); |
|
| 105 | +return array_combine($aNames, $aFullNames); |
|
| 106 | +} |
|
| 107 | 107 | } |
@@ -15,163 +15,163 @@ |
||
| 15 | 15 | |
| 16 | 16 | class StorageTest extends TestCase |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * @var StorageManager |
| 20 | 20 | */ |
| 21 | - protected $xManager; |
|
| 21 | +protected $xManager; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * @var string |
| 25 | 25 | */ |
| 26 | - protected $sInputDir; |
|
| 26 | +protected $sInputDir; |
|
| 27 | 27 | |
| 28 | - public function setUp(): void |
|
| 29 | - { |
|
| 30 | - $this->sInputDir = dirname(__DIR__) . '/files'; |
|
| 31 | - $this->xManager = storage(); |
|
| 32 | - } |
|
| 28 | +public function setUp(): void |
|
| 29 | +{ |
|
| 30 | +$this->sInputDir = dirname(__DIR__) . '/files'; |
|
| 31 | +$this->xManager = storage(); |
|
| 32 | +} |
|
| 33 | 33 | |
| 34 | - public function tearDown(): void |
|
| 35 | - { |
|
| 36 | - jaxon()->reset(); |
|
| 37 | - parent::tearDown(); |
|
| 38 | - } |
|
| 34 | +public function tearDown(): void |
|
| 35 | +{ |
|
| 36 | +jaxon()->reset(); |
|
| 37 | +parent::tearDown(); |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @throws Exception |
| 42 | 42 | */ |
| 43 | - public function testStorageReader() |
|
| 44 | - { |
|
| 45 | - $xInputStorage = $this->xManager->adapter('local')->make($this->sInputDir); |
|
| 46 | - $sInputContent = $xInputStorage->read('hello.txt'); |
|
| 47 | - |
|
| 48 | - $this->assertEquals(file_get_contents("{$this->sInputDir}/hello.txt"), $sInputContent); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function testAdapterAndDirOptions() |
|
| 52 | - { |
|
| 53 | - jaxon()->config()->setAppOptions([ |
|
| 54 | - 'adapters' => [ |
|
| 55 | - 'files' => [ |
|
| 56 | - 'alias' => 'local', |
|
| 57 | - 'options' => [ |
|
| 58 | - 'lazyRootCreation' => false, // Create dirs if they don't exist. |
|
| 59 | - ], |
|
| 60 | - ], |
|
| 61 | - ], |
|
| 62 | - 'stores' => [ |
|
| 63 | - 'files' => [ |
|
| 64 | - 'adapter' => 'files', |
|
| 65 | - 'dir' => $this->sInputDir, |
|
| 66 | - 'options' => [ |
|
| 67 | - 'config' => [ |
|
| 68 | - 'public_url' => '/static/files', |
|
| 69 | - ], |
|
| 70 | - ], |
|
| 71 | - ], |
|
| 72 | - ], |
|
| 73 | - ], 'storage'); |
|
| 74 | - |
|
| 75 | - $xInputStorage = $this->xManager->get('files'); |
|
| 76 | - $sInputContent = $xInputStorage->read('hello.txt'); |
|
| 77 | - |
|
| 78 | - $this->assertEquals(file_get_contents("{$this->sInputDir}/hello.txt"), $sInputContent); |
|
| 79 | - $this->assertEquals('/static/files/hello.txt', $xInputStorage->publicUrl('hello.txt')); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - public function testWriteError() |
|
| 83 | - { |
|
| 84 | - jaxon()->config()->setAppOptions([ |
|
| 85 | - 'adapters' => [ |
|
| 86 | - 'files' => [ |
|
| 87 | - 'alias' => 'local', |
|
| 88 | - 'options' => [ |
|
| 89 | - 'lazyRootCreation' => true, // Don't create dirs if they don't exist. |
|
| 90 | - ], |
|
| 91 | - ], |
|
| 43 | +public function testStorageReader() |
|
| 44 | +{ |
|
| 45 | +$xInputStorage = $this->xManager->adapter('local')->make($this->sInputDir); |
|
| 46 | +$sInputContent = $xInputStorage->read('hello.txt'); |
|
| 47 | + |
|
| 48 | +$this->assertEquals(file_get_contents("{$this->sInputDir}/hello.txt"), $sInputContent); |
|
| 49 | +} |
|
| 50 | + |
|
| 51 | +public function testAdapterAndDirOptions() |
|
| 52 | +{ |
|
| 53 | +jaxon()->config()->setAppOptions([ |
|
| 54 | +'adapters' => [ |
|
| 55 | + 'files' => [ |
|
| 56 | + 'alias' => 'local', |
|
| 57 | + 'options' => [ |
|
| 58 | + 'lazyRootCreation' => false, // Create dirs if they don't exist. |
|
| 59 | + ], |
|
| 60 | + ], |
|
| 61 | +], |
|
| 62 | +'stores' => [ |
|
| 63 | + 'files' => [ |
|
| 64 | + 'adapter' => 'files', |
|
| 65 | + 'dir' => $this->sInputDir, |
|
| 66 | + 'options' => [ |
|
| 67 | + 'config' => [ |
|
| 68 | + 'public_url' => '/static/files', |
|
| 92 | 69 | ], |
| 93 | - 'stores' => [ |
|
| 94 | - 'files' => [ |
|
| 95 | - 'adapter' => 'files', |
|
| 96 | - 'dir' => dirname(__DIR__ . '/files'), |
|
| 97 | - 'options' => [ |
|
| 98 | - 'config' => [ |
|
| 99 | - 'public_url' => '/static/files', |
|
| 100 | - ], |
|
| 101 | - ], |
|
| 102 | - ], |
|
| 70 | + ], |
|
| 71 | + ], |
|
| 72 | +], |
|
| 73 | +], 'storage'); |
|
| 74 | + |
|
| 75 | +$xInputStorage = $this->xManager->get('files'); |
|
| 76 | +$sInputContent = $xInputStorage->read('hello.txt'); |
|
| 77 | + |
|
| 78 | +$this->assertEquals(file_get_contents("{$this->sInputDir}/hello.txt"), $sInputContent); |
|
| 79 | +$this->assertEquals('/static/files/hello.txt', $xInputStorage->publicUrl('hello.txt')); |
|
| 80 | +} |
|
| 81 | + |
|
| 82 | +public function testWriteError() |
|
| 83 | +{ |
|
| 84 | +jaxon()->config()->setAppOptions([ |
|
| 85 | +'adapters' => [ |
|
| 86 | + 'files' => [ |
|
| 87 | + 'alias' => 'local', |
|
| 88 | + 'options' => [ |
|
| 89 | + 'lazyRootCreation' => true, // Don't create dirs if they don't exist. |
|
| 90 | + ], |
|
| 91 | + ], |
|
| 92 | +], |
|
| 93 | +'stores' => [ |
|
| 94 | + 'files' => [ |
|
| 95 | + 'adapter' => 'files', |
|
| 96 | + 'dir' => dirname(__DIR__ . '/files'), |
|
| 97 | + 'options' => [ |
|
| 98 | + 'config' => [ |
|
| 99 | + 'public_url' => '/static/files', |
|
| 103 | 100 | ], |
| 104 | - ], 'storage'); |
|
| 105 | - |
|
| 106 | - $this->expectException(CorruptedPathDetected::class); |
|
| 107 | - $xInputStorage = $this->xManager->get('files'); |
|
| 108 | - $sInputContent = $xInputStorage->read("\0hello.txt"); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public function testStorageWriter() |
|
| 112 | - { |
|
| 113 | - $this->xManager->register('memory', fn() => new InMemoryFilesystemAdapter()); |
|
| 114 | - jaxon()->config()->setAppOptions([ |
|
| 115 | - 'adapter' => 'memory', |
|
| 116 | - 'dir' => 'files', |
|
| 117 | - 'options' => [], |
|
| 118 | - ], 'storage.stores.memory'); |
|
| 119 | - |
|
| 120 | - $xInputStorage = $this->xManager->adapter('local')->make($this->sInputDir); |
|
| 121 | - $sInputContent = $xInputStorage->read('hello.txt'); |
|
| 122 | - |
|
| 123 | - $xOutputStorage = $this->xManager->get('memory'); |
|
| 124 | - $xOutputStorage->write('hello.txt', $sInputContent); |
|
| 125 | - $sOutputContent = $xOutputStorage->read('hello.txt'); |
|
| 126 | - |
|
| 127 | - $this->assertEquals($sOutputContent, $sInputContent); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - public function testErrorUnknownAdapter() |
|
| 131 | - { |
|
| 132 | - $this->expectException(Exception::class); |
|
| 133 | - $xUnknownStorage = $this->xManager->adapter('unknown')->make($this->sInputDir); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - public function testErrorUnknownConfig() |
|
| 137 | - { |
|
| 138 | - $this->expectException(Exception::class); |
|
| 139 | - $xUnknownStorage = $this->xManager->get('unknown'); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - public function testErrorIncorrectConfigAdapter() |
|
| 143 | - { |
|
| 144 | - jaxon()->config()->setAppOptions([ |
|
| 145 | - 'adapter' => null, |
|
| 146 | - 'dir' => 'files', |
|
| 147 | - 'options' => [], |
|
| 148 | - ], 'storage.stores.custom'); |
|
| 149 | - |
|
| 150 | - $this->expectException(Exception::class); |
|
| 151 | - $xErrorStorage = $this->xManager->get('custom'); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - public function testErrorIncorrectConfigDir() |
|
| 155 | - { |
|
| 156 | - jaxon()->config()->setAppOptions([ |
|
| 157 | - 'adapter' => 'memory', |
|
| 158 | - 'dir' => null, |
|
| 159 | - 'options' => [], |
|
| 160 | - ], 'storage.stores.custom'); |
|
| 161 | - |
|
| 162 | - $this->expectException(Exception::class); |
|
| 163 | - $xErrorStorage = $this->xManager->get('custom'); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - public function testErrorIncorrectConfigOptions() |
|
| 167 | - { |
|
| 168 | - jaxon()->config()->setAppOptions([ |
|
| 169 | - 'adapter' => 'memory', |
|
| 170 | - 'dir' => 'files', |
|
| 171 | - 'options' => null, |
|
| 172 | - ], 'storage.stores.custom'); |
|
| 173 | - |
|
| 174 | - $this->expectException(Exception::class); |
|
| 175 | - $xErrorStorage = $this->xManager->get('custom'); |
|
| 176 | - } |
|
| 101 | + ], |
|
| 102 | + ], |
|
| 103 | +], |
|
| 104 | +], 'storage'); |
|
| 105 | + |
|
| 106 | +$this->expectException(CorruptedPathDetected::class); |
|
| 107 | +$xInputStorage = $this->xManager->get('files'); |
|
| 108 | +$sInputContent = $xInputStorage->read("\0hello.txt"); |
|
| 109 | +} |
|
| 110 | + |
|
| 111 | +public function testStorageWriter() |
|
| 112 | +{ |
|
| 113 | +$this->xManager->register('memory', fn() => new InMemoryFilesystemAdapter()); |
|
| 114 | +jaxon()->config()->setAppOptions([ |
|
| 115 | +'adapter' => 'memory', |
|
| 116 | +'dir' => 'files', |
|
| 117 | +'options' => [], |
|
| 118 | +], 'storage.stores.memory'); |
|
| 119 | + |
|
| 120 | +$xInputStorage = $this->xManager->adapter('local')->make($this->sInputDir); |
|
| 121 | +$sInputContent = $xInputStorage->read('hello.txt'); |
|
| 122 | + |
|
| 123 | +$xOutputStorage = $this->xManager->get('memory'); |
|
| 124 | +$xOutputStorage->write('hello.txt', $sInputContent); |
|
| 125 | +$sOutputContent = $xOutputStorage->read('hello.txt'); |
|
| 126 | + |
|
| 127 | +$this->assertEquals($sOutputContent, $sInputContent); |
|
| 128 | +} |
|
| 129 | + |
|
| 130 | +public function testErrorUnknownAdapter() |
|
| 131 | +{ |
|
| 132 | +$this->expectException(Exception::class); |
|
| 133 | +$xUnknownStorage = $this->xManager->adapter('unknown')->make($this->sInputDir); |
|
| 134 | +} |
|
| 135 | + |
|
| 136 | +public function testErrorUnknownConfig() |
|
| 137 | +{ |
|
| 138 | +$this->expectException(Exception::class); |
|
| 139 | +$xUnknownStorage = $this->xManager->get('unknown'); |
|
| 140 | +} |
|
| 141 | + |
|
| 142 | +public function testErrorIncorrectConfigAdapter() |
|
| 143 | +{ |
|
| 144 | +jaxon()->config()->setAppOptions([ |
|
| 145 | +'adapter' => null, |
|
| 146 | +'dir' => 'files', |
|
| 147 | +'options' => [], |
|
| 148 | +], 'storage.stores.custom'); |
|
| 149 | + |
|
| 150 | +$this->expectException(Exception::class); |
|
| 151 | +$xErrorStorage = $this->xManager->get('custom'); |
|
| 152 | +} |
|
| 153 | + |
|
| 154 | +public function testErrorIncorrectConfigDir() |
|
| 155 | +{ |
|
| 156 | +jaxon()->config()->setAppOptions([ |
|
| 157 | +'adapter' => 'memory', |
|
| 158 | +'dir' => null, |
|
| 159 | +'options' => [], |
|
| 160 | +], 'storage.stores.custom'); |
|
| 161 | + |
|
| 162 | +$this->expectException(Exception::class); |
|
| 163 | +$xErrorStorage = $this->xManager->get('custom'); |
|
| 164 | +} |
|
| 165 | + |
|
| 166 | +public function testErrorIncorrectConfigOptions() |
|
| 167 | +{ |
|
| 168 | +jaxon()->config()->setAppOptions([ |
|
| 169 | +'adapter' => 'memory', |
|
| 170 | +'dir' => 'files', |
|
| 171 | +'options' => null, |
|
| 172 | +], 'storage.stores.custom'); |
|
| 173 | + |
|
| 174 | +$this->expectException(Exception::class); |
|
| 175 | +$xErrorStorage = $this->xManager->get('custom'); |
|
| 176 | +} |
|
| 177 | 177 | } |