-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from gacela-project/feature/custom-caching-dir
Allow defining custom cache directory name
- Loading branch information
Showing
11 changed files
with
112 additions
and
6 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
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
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
37 changes: 37 additions & 0 deletions
37
tests/Feature/Framework/CustomCacheDirectory/FeatureTest.php
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GacelaTest\Feature\Framework\CustomCacheDirectory; | ||
|
||
use Gacela\Framework\Bootstrap\GacelaConfig; | ||
use Gacela\Framework\ClassResolver\ClassNameCache; | ||
use Gacela\Framework\ClassResolver\DocBlockService\CustomServicesCache; | ||
use Gacela\Framework\Gacela; | ||
use GacelaTest\Feature\Util\DirectoryUtil; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class FeatureTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void { | ||
$config->addAppConfig('config/*.php'); | ||
$config->setCacheDirectory('custom-caching-dir'); | ||
}); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
DirectoryUtil::removeDir(__DIR__ . '/custom-caching-dir'); | ||
} | ||
|
||
public function test_custom_caching_dir(): void | ||
{ | ||
$facade = new Module\Facade(); | ||
self::assertSame('name', $facade->getName()); | ||
|
||
self::assertFileExists(__DIR__ . '/custom-caching-dir/' . ClassNameCache::CACHE_FILENAME); | ||
self::assertFileExists(__DIR__ . '/custom-caching-dir/' . CustomServicesCache::CACHE_FILENAME); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/Feature/Framework/CustomCacheDirectory/Module/Facade.php
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,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GacelaTest\Feature\Framework\CustomCacheDirectory\Module; | ||
|
||
use Gacela\Framework\AbstractFacade; | ||
use Gacela\Framework\DocBlockResolverAwareTrait; | ||
use GacelaTest\Feature\Framework\CustomCacheDirectory\Module\Persistence\FakeRepository; | ||
|
||
/** | ||
* @method FakeRepository getRepository() | ||
*/ | ||
final class Facade extends AbstractFacade | ||
{ | ||
use DocBlockResolverAwareTrait; | ||
|
||
public function getName(): string | ||
{ | ||
return $this->getRepository()->findName(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/Feature/Framework/CustomCacheDirectory/Module/Persistence/FakeRepository.php
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GacelaTest\Feature\Framework\CustomCacheDirectory\Module\Persistence; | ||
|
||
final class FakeRepository | ||
{ | ||
public function findName(): string | ||
{ | ||
return 'name'; | ||
} | ||
} |
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