-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Swis\Melvin\Tests\Integration; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Swis\Melvin\Client; | ||
use Swis\Melvin\Enums\AreaType; | ||
use Swis\Melvin\Models\Area; | ||
use Swis\Melvin\SituationFilterParameters; | ||
|
||
class SituationsTest extends TestCase | ||
{ | ||
private Client $client; | ||
|
||
public static function setUpBeforeClass(): void | ||
{ | ||
if (!getenv('MELVIN_USERNAME') || !getenv('MELVIN_PASSWORD')) { | ||
self::markTestSkipped('Missing Melvin credentials.'); | ||
} | ||
} | ||
|
||
/** | ||
* @dataProvider areaIdProvider | ||
* | ||
* @param int $areaId | ||
*/ | ||
public function testSituations(int $areaId): void | ||
{ | ||
$params = (new SituationFilterParameters()) | ||
->setIncludeDetours(true) | ||
->setAreaIds([$areaId]); | ||
|
||
$situations = $this->client()->situations()->export($params); | ||
|
||
$this->assertNotEmpty($situations); | ||
} | ||
|
||
public function areaIdProvider(): \Generator | ||
{ | ||
$areas = array_filter( | ||
$this->client()->areas()->all(), | ||
static fn (Area $area) => $area->type->equals(AreaType::PROVINCE()) | ||
); | ||
|
||
foreach ($areas as $area) { | ||
yield $area->name => [$area->id]; | ||
} | ||
} | ||
|
||
private function client(): Client | ||
{ | ||
if (!isset($this->client)) { | ||
$this->client = Client::create(getenv('MELVIN_USERNAME'), getenv('MELVIN_PASSWORD')); | ||
} | ||
|
||
return $this->client; | ||
} | ||
} |