From e41c2c0ae138e0972228a91ad091d3fe60be66bd Mon Sep 17 00:00:00 2001 From: fedy95 Date: Sun, 31 Jan 2021 15:04:57 +0300 Subject: [PATCH] add-front-to-weather_site --- docker-compose.yaml | 7 +++++++ src/Repository/HistoryRepository.php | 10 +++++----- src/Repository/HistoryRepositoryInterface.php | 4 ++-- tests/api/Method/Weather/GetByDateMethodCest.php | 5 ++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index b856d1e..f451350 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,9 @@ version: "3" +networks: + gate: + driver: bridge + services: mysql: image: mysql:5.7 @@ -44,3 +48,6 @@ services: - ./devops/docker/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf ports: - "8$PROJECT_ID:80" + networks: + - default + - gate \ No newline at end of file diff --git a/src/Repository/HistoryRepository.php b/src/Repository/HistoryRepository.php index c1ae53d..27bfee5 100644 --- a/src/Repository/HistoryRepository.php +++ b/src/Repository/HistoryRepository.php @@ -16,18 +16,18 @@ class HistoryRepository extends ServiceEntityRepository implements HistoryReposi parent::__construct($registry, History::class); } - public function findTempByDateAt(DateTimeInterface $date_at): ?float + public function findTempByDateAt(DateTimeInterface $date_at): array { $history = $this->findOneBy(['date_at' => $date_at]); if (null !== $history) { - return $history->getTemp(); + return ['temp' => $history->getTemp()]; } - return null; + return []; } - public function findWithLimit(int $limit): ?array + public function findWithLimit(int $limit): array { $histories = $this->findBy([], ['date_at' => 'DESC'], $limit); @@ -43,6 +43,6 @@ class HistoryRepository extends ServiceEntityRepository implements HistoryReposi return $result; } - return null; + return []; } } diff --git a/src/Repository/HistoryRepositoryInterface.php b/src/Repository/HistoryRepositoryInterface.php index da85ab6..779d78d 100644 --- a/src/Repository/HistoryRepositoryInterface.php +++ b/src/Repository/HistoryRepositoryInterface.php @@ -8,7 +8,7 @@ use DateTimeInterface; interface HistoryRepositoryInterface { - public function findTempByDateAt(DateTimeInterface $date_at): ?float; + public function findTempByDateAt(DateTimeInterface $date_at): array; - public function findWithLimit(int $limit): ?array; + public function findWithLimit(int $limit): array; } diff --git a/tests/api/Method/Weather/GetByDateMethodCest.php b/tests/api/Method/Weather/GetByDateMethodCest.php index 9f8442c..cf437ea 100644 --- a/tests/api/Method/Weather/GetByDateMethodCest.php +++ b/tests/api/Method/Weather/GetByDateMethodCest.php @@ -43,7 +43,6 @@ class GetByDateMethodCest 'seeResponseMatchesJsonType' => [ 'jsonrpc' => 'string', 'id' => 'integer', - 'result' => 'float', ], ], [ @@ -54,12 +53,12 @@ class GetByDateMethodCest 'seeResponseContainsJson' => [ 'jsonrpc' => '2.0', 'id' => 1, - 'result' => null, + 'result' => [], ], 'seeResponseMatchesJsonType' => [ 'jsonrpc' => 'string', 'id' => 'integer', - 'result' => 'null', + 'result' => 'array', ], ], [