Skip to content

Commit

Permalink
Updated http provider
Browse files Browse the repository at this point in the history
  • Loading branch information
lostfocus committed Feb 27, 2024
1 parent 6c5113d commit eac1613
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.2] - 2024-02-27

### Changed

* Updated the HTTP provider to replace HTTPlug factories by PSR-17

## [0.3.1] - 2023-09-23

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

![Packagist Version](https://img.shields.io/packagist/v/php-weather/open-meteo)
![PHP Weather Common Version](https://img.shields.io/badge/phpweather--core-0.4.*-brightgreen)
![PHP Weather HTTP Provider Version](https://img.shields.io/badge/phpweather--http--provider-0.5.*-brightgreen)
![PHP Weather HTTP Provider Version](https://img.shields.io/badge/phpweather--http--provider-0.6.*-brightgreen)
![GitHub Release Date](https://img.shields.io/github/release-date/php-weather/open-meteo)
![GitHub commits since tagged version](https://img.shields.io/github/commits-since/php-weather/open-meteo/0.3.1)
![GitHub commits since tagged version](https://img.shields.io/github/commits-since/php-weather/open-meteo/0.3.2)
![GitHub last commit](https://img.shields.io/github/last-commit/php-weather/open-meteo)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/php-weather/open-meteo/php.yml?branch=main)
![GitHub](https://img.shields.io/github/license/php-weather/open-meteo)
Expand Down
2 changes: 1 addition & 1 deletion Src/OpenMeteo.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function mapRawData(float $latitude, float $longitude, array $rawData,

if ($weatherDateTime < $currentDateTime) {
$weather->setType(Type::HISTORICAL);
} elseif ($weatherDateTime === $currentDateTime) {
} elseif ($weatherDateTime == $currentDateTime) {
$weather->setType(Type::CURRENT);
} else {
$weather->setType(Type::FORECAST);
Expand Down
10 changes: 5 additions & 5 deletions Tests/OpenMeteoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
namespace PhpWeather\Provider\OpenMeteo;

use GuzzleHttp\Psr7\Stream;
use Http\Client\HttpClient;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use PhpWeather\Common\WeatherQuery;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class OpenMeteoTest extends TestCase
{
private MockObject|HttpClient $client;
private MockObject|ClientInterface $client;
private MockObject|RequestFactoryInterface $requestFactory;
private OpenMeteo $provider;

public function setUp(): void
{
$this->client = $this->createMock(HttpClient::class);
$this->client = $this->createMock(ClientInterface::class);
$this->requestFactory = $this->createMock(RequestFactoryInterface::class);

$this->provider = new OpenMeteo($this->client, $this->requestFactory);
Expand All @@ -30,7 +30,7 @@ public function testCurrentWeather(): void
{
$latitude = 47.8739259;
$longitude = 8.0043961;
$datetime = (new \DateTime())->setTimezone(new \DateTimeZone('UTC'))->setDate(2022, 07,31)->setTime(16,00);
$datetime = (new \DateTime())->setTimezone(new \DateTimeZone('UTC'))->setDate(2022, 07, 31)->setTime(16, 00);
$testQuery = WeatherQuery::create($latitude, $longitude, $datetime);
$testString = 'https://api.open-meteo.com/v1/forecast?latitude=47.8739259&longitude=8.0043961&hourly=temperature_2m,relativehumidity_2m,dewpoint_2m,apparent_temperature,pressure_msl,precipitation,weathercode,cloudcover,windspeed_10m,winddirection_10m&timezone=UTC&current_weather=true&start_date=2022-07-31&end_date=2022-08-01';

Expand All @@ -39,7 +39,7 @@ public function testCurrentWeather(): void

$responseBodyString = file_get_contents(__DIR__.'/resources/currentWeather.json');
$response = $this->createMock(ResponseInterface::class);
if ($resource = fopen('data://text/plain,' . $responseBodyString, 'rb')) {
if ($resource = fopen('data://text/plain,'.$responseBodyString, 'rb')) {
$reponseStream = new Stream($resource);
} else {
$this->fail();
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
"require": {
"php": "^8",
"ext-json": "*",
"php-weather/http-provider": "0.5.*",
"php-weather/http-provider": "0.6.*",
"php-weather/core": "0.4.*"
},
"require-dev": {
"jetbrains/phpstorm-attributes": "^1.0",
"php-http/guzzle7-adapter": "^1.0",
"phpstan/phpstan": "^1.6",
"phpunit/phpunit": ">=8.0"
Expand Down

0 comments on commit eac1613

Please sign in to comment.