-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: added air pollution entities tests
- Loading branch information
1 parent
e8a6665
commit e35e1e2
Showing
9 changed files
with
162 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\OpenWeatherMap\Test\Unit\AirPollution; | ||
|
||
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirPollutionCollection; | ||
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirPollutionData; | ||
use ProgrammatorDev\OpenWeatherMap\Entity\Coordinate; | ||
use ProgrammatorDev\OpenWeatherMap\Test\AbstractTest; | ||
|
||
class AirPollutionCollectionTest extends AbstractTest | ||
{ | ||
public function testMethods() | ||
{ | ||
$entity = new AirPollutionCollection([ | ||
'coord' => [ | ||
'lat' => 50, | ||
'lon' => 50 | ||
], | ||
'list' => [ | ||
[ | ||
'dt' => 1715279409, | ||
'main' => [ | ||
'aqi' => 1 | ||
], | ||
'components' => [ | ||
'co' => 100, | ||
'no' => 0, | ||
'no2' => 1, | ||
'o3' => 100, | ||
'so2' => 1, | ||
'pm2_5' => 1, | ||
'pm10' => 1, | ||
'nh3' => 1 | ||
] | ||
] | ||
] | ||
]); | ||
|
||
$this->assertInstanceOf(Coordinate::class, $entity->getCoordinate()); | ||
$this->assertContainsOnlyInstancesOf(AirPollutionData::class, $entity->getData()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\OpenWeatherMap\Test\Unit\AirPollution; | ||
|
||
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirPollutionData; | ||
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirQuality; | ||
use ProgrammatorDev\OpenWeatherMap\Test\AbstractTest; | ||
|
||
class AirPollutionDataTest extends AbstractTest | ||
{ | ||
public function testMethods() | ||
{ | ||
$entity = new AirPollutionData([ | ||
'dt' => 1715279409, | ||
'main' => [ | ||
'aqi' => 1 | ||
], | ||
'components' => [ | ||
'co' => 100, | ||
'no' => 0, | ||
'no2' => 1, | ||
'o3' => 100, | ||
'so2' => 1, | ||
'pm2_5' => 1, | ||
'pm10' => 1, | ||
'nh3' => 1 | ||
] | ||
]); | ||
|
||
$this->assertInstanceOf(\DateTimeImmutable::class, $entity->getDateTime()); | ||
$this->assertInstanceOf(AirQuality::class, $entity->getAirQuality()); | ||
$this->assertSame(100.0, $entity->getCarbonMonoxide()); | ||
$this->assertSame(0.0, $entity->getNitrogenMonoxide()); | ||
$this->assertSame(1.0, $entity->getNitrogenDioxide()); | ||
$this->assertSame(100.0, $entity->getOzone()); | ||
$this->assertSame(1.0, $entity->getSulphurDioxide()); | ||
$this->assertSame(1.0, $entity->getFineParticulateMatter()); | ||
$this->assertSame(1.0, $entity->getCoarseParticulateMatter()); | ||
$this->assertSame(1.0, $entity->getAmmonia()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\OpenWeatherMap\Test\Unit\AirPollution; | ||
|
||
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirPollution; | ||
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirQuality; | ||
use ProgrammatorDev\OpenWeatherMap\Entity\Coordinate; | ||
use ProgrammatorDev\OpenWeatherMap\Test\AbstractTest; | ||
|
||
class AirPollutionTest extends AbstractTest | ||
{ | ||
public function testMethods() | ||
{ | ||
$entity = new AirPollution([ | ||
'coord' => [ | ||
'lat' => 50, | ||
'lon' => 50 | ||
], | ||
'list' => [ | ||
[ | ||
'dt' => 1715279409, | ||
'main' => [ | ||
'aqi' => 1 | ||
], | ||
'components' => [ | ||
'co' => 100, | ||
'no' => 0, | ||
'no2' => 1, | ||
'o3' => 100, | ||
'so2' => 1, | ||
'pm2_5' => 1, | ||
'pm10' => 1, | ||
'nh3' => 1 | ||
] | ||
] | ||
] | ||
]); | ||
|
||
$this->assertInstanceOf(Coordinate::class, $entity->getCoordinate()); | ||
$this->assertInstanceOf(\DateTimeImmutable::class, $entity->getDateTime()); | ||
$this->assertInstanceOf(AirQuality::class, $entity->getAirQuality()); | ||
$this->assertSame(100.0, $entity->getCarbonMonoxide()); | ||
$this->assertSame(0.0, $entity->getNitrogenMonoxide()); | ||
$this->assertSame(1.0, $entity->getNitrogenDioxide()); | ||
$this->assertSame(100.0, $entity->getOzone()); | ||
$this->assertSame(1.0, $entity->getSulphurDioxide()); | ||
$this->assertSame(1.0, $entity->getFineParticulateMatter()); | ||
$this->assertSame(1.0, $entity->getCoarseParticulateMatter()); | ||
$this->assertSame(1.0, $entity->getAmmonia()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\OpenWeatherMap\Test\Unit\AirPollution; | ||
|
||
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirQuality; | ||
use ProgrammatorDev\OpenWeatherMap\Test\AbstractTest; | ||
|
||
class AirQualityTest extends AbstractTest | ||
{ | ||
public function testMethods() | ||
{ | ||
$entity = new AirQuality([ | ||
'aqi' => 1 | ||
]); | ||
|
||
$this->assertSame(1, $entity->getIndex()); | ||
$this->assertSame('Good', $entity->getQualitativeName()); | ||
} | ||
} |