Skip to content

Commit 944fc6f

Browse files
committed
Container: Add tests
1 parent 61c9585 commit 944fc6f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/unit/Toolkit/Container/ApplicationTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
namespace Salient\Tests\Container;
44

55
use Psr\Container\ContainerInterface as PsrContainerInterface;
6+
use Salient\Cache\CacheStore;
67
use Salient\Container\Application;
78
use Salient\Container\Container;
89
use Salient\Contract\Container\ApplicationInterface;
910
use Salient\Contract\Container\ContainerInterface;
11+
use Salient\Core\Facade\Cache;
1012
use Salient\Core\Facade\Config;
1113
use Salient\Core\Facade\Console;
1214
use Salient\Core\Facade\Err;
1315
use Salient\Core\Facade\Sync;
16+
use Salient\Sync\SyncStore;
1417
use Salient\Tests\Sync\Entity\Provider\PostProvider;
1518
use Salient\Tests\Sync\Entity\Post;
1619
use Salient\Tests\Sync\Provider\JsonPlaceholderApi;
@@ -314,6 +317,38 @@ public function testRecordHarWithSync(): void
314317
$this->assertStringEndsWith('-' . $uuid . '.har', $file);
315318
}
316319

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+
317352
/**
318353
* @param non-empty-string|null $name
319354
* @param int-mask-of<Env::APPLY_*> $envFlags

0 commit comments

Comments
 (0)