Skip to content

Commit

Permalink
hotfix: disable_domain -> disable_method on souin cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mattvb91 committed Jul 26, 2022
1 parent 7792b4a commit 6f92b95
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Config/Apps/Cache/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ class Key implements Arrayable

private bool $_disable_body;

private bool $_disable_domain;
private bool $_disable_method;

public function __construct(
string $pattern,
bool $disable_host = false,
bool $disable_body = false,
bool $disable_domain = false)
bool $disable_method = false)
{
$this->_pattern = $pattern;
$this->_disable_host = $disable_host;
$this->_disable_body = $disable_body;
$this->_disable_domain = $disable_domain;
$this->_disable_method = $disable_method;
}

public function getPattern(): string
Expand All @@ -45,9 +45,9 @@ public function setDisableBody(bool $disable_body): static
return $this;
}

public function setDisableDomain(bool $disable_domain): static
public function setDisableMethod(bool $disable_domain): static
{
$this->_disable_domain = $disable_domain;
$this->_disable_method = $disable_domain;

return $this;
}
Expand All @@ -57,7 +57,7 @@ public function toArray(): array
return [
'disable_host' => $this->_disable_host,
'disable_body' => $this->_disable_body,
'disable_domain' => $this->_disable_domain,
'disable_method' => $this->_disable_method,
];
}
}
20 changes: 20 additions & 0 deletions tests/Integration/Apps/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use mattvb91\CaddyPhp\Caddy;
use mattvb91\CaddyPhp\Config\Apps\Cache;
use mattvb91\CaddyPhp\Config\Apps\Http;
use mattvb91\CaddyPhp\Config\Logs\LogLevel;
use Tests\TestCase;

class CacheTest extends TestCase
Expand Down Expand Up @@ -41,4 +42,23 @@ public function test_request_returns_cache_header()
$this->assertEquals('cache test', $request->getBody()->getContents());
$this->assertStringContainsString('Souin;', $request->getHeader('cache-status')[0]);
}

/**
* @coversNothing
*/
public function test_keys()
{
$caddy = new Caddy();

$cacheApi = new Cache\Api();
$cacheApi->setBasePath('/__cache');

$cache = new Cache($cacheApi);
$cache->setLogLevel(LogLevel::DEBUG)
->setStale('0s')
->addCacheKey(new Cache\Key(pattern: '/_next\/static/', disable_host: true));

$caddy->addApp($cache);
$this->assertCaddyConfigLoaded($caddy);
}
}

0 comments on commit 6f92b95

Please sign in to comment.