Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed cached files containing encoded characters
- Loading branch information
bencroker
committed
Sep 9, 2020
1 parent
abef8d3
commit 4305794
Showing
4 changed files
with
152 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) PutYourLightsOn | ||
*/ | ||
|
||
namespace putyourlightson\blitztests\unit; | ||
|
||
use Codeception\Test\Unit; | ||
use putyourlightson\blitz\Blitz; | ||
use putyourlightson\blitz\models\SiteUriModel; | ||
use UnitTester; | ||
|
||
/** | ||
* @author PutYourLightsOn | ||
* @package Blitz | ||
* @since 3.6.9 | ||
*/ | ||
|
||
class FileStorageTest extends Unit | ||
{ | ||
// Properties | ||
// ========================================================================= | ||
|
||
/** | ||
* @var UnitTester | ||
*/ | ||
protected $tester; | ||
|
||
/** | ||
* @var SiteUriModel | ||
*/ | ||
private $siteUri; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $output = 'xyz'; | ||
|
||
// Protected methods | ||
// ========================================================================= | ||
|
||
protected function _before() | ||
{ | ||
parent::_before(); | ||
|
||
Blitz::$plugin->generateCache->options->cachingEnabled = true; | ||
Blitz::$plugin->cacheStorage->deleteAll(); | ||
Blitz::$plugin->flushCache->flushAll(); | ||
|
||
$this->siteUri = new SiteUriModel([ | ||
'siteId' => 1, | ||
'uri' => 'möbelträgerfüße', | ||
]); | ||
|
||
Blitz::$plugin->cacheStorage->save($this->output, $this->siteUri); | ||
} | ||
|
||
// Public methods | ||
// ========================================================================= | ||
|
||
public function testSave() | ||
{ | ||
$value = Blitz::$plugin->cacheStorage->get($this->siteUri); | ||
$this->assertStringContainsString($this->output, $value); | ||
} | ||
|
||
public function testSaveDecoded() | ||
{ | ||
$this->siteUri->uri = rawurldecode($this->siteUri->uri); | ||
$value = Blitz::$plugin->cacheStorage->get($this->siteUri); | ||
$this->assertStringContainsString($this->output, $value); | ||
} | ||
|
||
public function testDelete() | ||
{ | ||
Blitz::$plugin->cacheStorage->deleteUris([$this->siteUri]); | ||
$value = Blitz::$plugin->cacheStorage->get($this->siteUri); | ||
$this->assertEmpty($value); | ||
} | ||
|
||
public function testDeleteDecoded() | ||
{ | ||
$this->siteUri->uri = rawurldecode($this->siteUri->uri); | ||
Blitz::$plugin->cacheStorage->deleteUris([$this->siteUri]); | ||
$value = Blitz::$plugin->cacheStorage->get($this->siteUri); | ||
$this->assertEmpty($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters