|
3 | 3 | namespace Salient\Tests\Container; |
4 | 4 |
|
5 | 5 | use Psr\Container\ContainerInterface as PsrContainerInterface; |
| 6 | +use Salient\Cache\CacheStore; |
6 | 7 | use Salient\Container\Application; |
7 | 8 | use Salient\Container\Container; |
8 | 9 | use Salient\Contract\Container\ApplicationInterface; |
9 | 10 | use Salient\Contract\Container\ContainerInterface; |
| 11 | +use Salient\Core\Facade\Cache; |
10 | 12 | use Salient\Core\Facade\Config; |
11 | 13 | use Salient\Core\Facade\Console; |
12 | 14 | use Salient\Core\Facade\Err; |
13 | 15 | use Salient\Core\Facade\Sync; |
| 16 | +use Salient\Sync\SyncStore; |
14 | 17 | use Salient\Tests\Sync\Entity\Provider\PostProvider; |
15 | 18 | use Salient\Tests\Sync\Entity\Post; |
16 | 19 | use Salient\Tests\Sync\Provider\JsonPlaceholderApi; |
@@ -314,6 +317,38 @@ public function testRecordHarWithSync(): void |
314 | 317 | $this->assertStringEndsWith('-' . $uuid . '.har', $file); |
315 | 318 | } |
316 | 319 |
|
| 320 | + public function testHasCache(): void |
| 321 | + { |
| 322 | + $app = $this->getApp(); |
| 323 | + $this->assertFalse($app->hasCache()); |
| 324 | + Cache::getInstance(); |
| 325 | + $this->assertFalse($app->hasCache()); |
| 326 | + Cache::swap(new CacheStore($app->getCachePath() . '/cache.db')); |
| 327 | + $this->assertTrue($app->hasCache()); |
| 328 | + Cache::unload(); |
| 329 | + $this->assertFalse($app->hasCache()); |
| 330 | + $app->startCache(); |
| 331 | + $this->assertTrue($app->hasCache()); |
| 332 | + $app->stopCache(); |
| 333 | + $this->assertFalse($app->hasCache()); |
| 334 | + } |
| 335 | + |
| 336 | + public function testHasSync(): void |
| 337 | + { |
| 338 | + $app = $this->getApp(); |
| 339 | + $this->assertFalse($app->hasSync()); |
| 340 | + Sync::getInstance(); |
| 341 | + $this->assertFalse($app->hasSync()); |
| 342 | + Sync::swap(new SyncStore($app->getDataPath() . '/sync.db')); |
| 343 | + $this->assertTrue($app->hasSync()); |
| 344 | + Sync::unload(); |
| 345 | + $this->assertFalse($app->hasSync()); |
| 346 | + $app->startSync(static::class, []); |
| 347 | + $this->assertTrue($app->hasSync()); |
| 348 | + $app->stopSync(); |
| 349 | + $this->assertFalse($app->hasSync()); |
| 350 | + } |
| 351 | + |
317 | 352 | /** |
318 | 353 | * @param non-empty-string|null $name |
319 | 354 | * @param int-mask-of<Env::APPLY_*> $envFlags |
|
0 commit comments