From fbcecb47ccc5dd67f98f76ff3e6028c46fa36300 Mon Sep 17 00:00:00 2001 From: leventcorapsiz Date: Sun, 19 May 2024 20:00:19 +0300 Subject: [PATCH] changed directory --- .../RedisRepository.php | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) rename tests/{Units => Repositories}/RedisRepository.php (82%) diff --git a/tests/Units/RedisRepository.php b/tests/Repositories/RedisRepository.php similarity index 82% rename from tests/Units/RedisRepository.php rename to tests/Repositories/RedisRepository.php index d94d78c..daf4669 100644 --- a/tests/Units/RedisRepository.php +++ b/tests/Repositories/RedisRepository.php @@ -1,5 +1,6 @@ redisFactory = Mockery::mock(RedisFactory::class); $this->connection = Mockery::mock(Connection::class); + $this->config = Mockery::mock(Repository::class); + $this->redisFactory ->shouldReceive('connection') ->andReturn($this->connection); - $this->repository = new RedisRepository($this->redisFactory); + $this->config + ->shouldReceive('get') + ->andReturn('top.connection'); + + $this->repository = new RedisRepository($this->redisFactory, $this->config); }); afterEach(function () { @@ -78,9 +85,8 @@ ->once() ->andReturn(json_encode(['averageRequestPerSecond' => 1, 'averageMemoryUsage' => 2, 'averageDuration' => 3])); - $summary = $this->repository->getRequestSummary(); - - expect($summary)->toBeInstanceOf(RequestSummary::class); + expect($this->repository->getRequestSummary()) + ->toBeInstanceOf(RequestSummary::class); }); it('fetches database summary from redis', function () { @@ -90,9 +96,8 @@ ->once() ->andReturn(json_encode(['averageQueryPerSecond' => 1, 'averageQueryDuration' => 2])); - $summary = $this->repository->getDatabaseSummary(); - - expect($summary)->toBeInstanceOf(DatabaseSummary::class); + expect($this->repository->getDatabaseSummary()) + ->toBeInstanceOf(DatabaseSummary::class); }); it('fetches cache summary from redis', function () { @@ -104,9 +109,8 @@ 'averageHitPerSecond' => 1, 'averageMissPerSecond' => 2, 'averageWritePerSecond' => 3 ])); - $summary = $this->repository->getCacheSummary(); - - expect($summary)->toBeInstanceOf(CacheSummary::class); + expect($this->repository->getCacheSummary()) + ->toBeInstanceOf(CacheSummary::class); }); it('fetches top routes from redis', function () { @@ -121,7 +125,6 @@ ] ])); - $routes = $this->repository->getTopRoutes(); - - expect($routes)->toBeInstanceOf(RouteCollection::class); + expect($this->repository->getTopRoutes()) + ->toBeInstanceOf(RouteCollection::class); });