Skip to content

Commit

Permalink
fix error PHPStan, update test case main method
Browse files Browse the repository at this point in the history
  • Loading branch information
warcooft committed Jul 30, 2024
1 parent 4115b8c commit d73de63
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
4 changes: 4 additions & 0 deletions system/Commands/Utilities/Optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ private function runCaching(?bool $enableConfigCache, ?bool $enableLocatorCache,

/**
* Disable Caching
*
* @return array<string, string>
*/
private function disableCaching(): array
{
Expand All @@ -191,6 +193,8 @@ private function disableCaching(): array
* Enable Caching
*
* @param array<string, bool|null> $options
*
* @return array<string, string>
*/
private function enableCaching(array $options): array
{
Expand Down
24 changes: 12 additions & 12 deletions tests/system/Commands/Utilities/OptimizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public function testEnableConfigCaching(): void
{
$command = new Optimize(service('logger'), service('commands'));

$enableCaching = $this->getPrivateMethodInvoker($command, 'enableCaching');
$runCaching = $this->getPrivateMethodInvoker($command, 'runCaching');

// private function enableCaching(?bool $enableConfigCache, ?bool $enableLocatorCache, ?bool $disable): void
$enableCaching(true, null, null);
// private function runCaching(?bool $enableConfigCache, ?bool $enableLocatorCache, ?bool $disable): void
$runCaching(true, null, null);

// Check if config caching is enabled
$this->assertFileContains('public bool $configCacheEnabled = true;', APPPATH . 'Config/Optimize.php');
Expand All @@ -54,10 +54,10 @@ public function testEnableLocatorCaching(): void
{
$command = new Optimize(service('logger'), service('commands'));

$enableCaching = $this->getPrivateMethodInvoker($command, 'enableCaching');
$runCaching = $this->getPrivateMethodInvoker($command, 'runCaching');

// private function enableCaching(?bool $enableConfigCache, ?bool $enableLocatorCache, ?bool $disable): void
$enableCaching(null, true, null);
// private function runCaching(?bool $enableConfigCache, ?bool $enableLocatorCache, ?bool $disable): void
$runCaching(null, true, null);

// Check if locator caching is enabled
$this->assertFileContains('public bool $locatorCacheEnabled = true;', APPPATH . 'Config/Optimize.php');
Expand All @@ -67,10 +67,10 @@ public function testDisableCaching(): void
{
$command = new Optimize(service('logger'), service('commands'));

$enableCaching = $this->getPrivateMethodInvoker($command, 'enableCaching');
$runCaching = $this->getPrivateMethodInvoker($command, 'runCaching');

// private function enableCaching(?bool $enableConfigCache, ?bool $enableLocatorCache, ?bool $disable): void
$enableCaching(null, null, true);
// private function runCaching(?bool $enableConfigCache, ?bool $enableLocatorCache, ?bool $disable): void
$runCaching(null, null, true);

// Check if both caches are disabled
$this->assertFileContains('public bool $configCacheEnabled = false;', APPPATH . 'Config/Optimize.php');
Expand All @@ -81,10 +81,10 @@ public function testWithoutOptions(): void
{
$command = new Optimize(service('logger'), service('commands'));

$enableCaching = $this->getPrivateMethodInvoker($command, 'enableCaching');
$runCaching = $this->getPrivateMethodInvoker($command, 'runCaching');

// private function enableCaching(?bool $enableConfigCache, ?bool $enableLocatorCache, ?bool $disable): void
$enableCaching(null, null, null);
// private function runCaching(?bool $enableConfigCache, ?bool $enableLocatorCache, ?bool $disable): void
$runCaching(null, null, null);

// Check if both caches are disabled
$this->assertFileContains('public bool $configCacheEnabled = true;', APPPATH . 'Config/Optimize.php');
Expand Down
15 changes: 15 additions & 0 deletions user_guide_src/source/installation/deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ The ``spark optimize`` command performs the following optimizations:
- Enabling `Config Caching`_
- Enabling `FileLocator Caching`_

If you want disable or restore the actions above, run ``spark optimize -d``
it will do a restore to default settings, as follow:

.. versionadded:: 4.6.0

- `Reinstall Dev Packages`_
- Disabling `Config Caching`_
- Disabling `FileLocator Caching`_

Available options:

- `-c` Enable only config caching.
- `-l` Enable only locator caching.
- `-d` Disable config and locator caching.

Composer Optimization
=====================

Expand Down

0 comments on commit d73de63

Please sign in to comment.