From f0001751cdc079d82dfa08a56c81328940125121 Mon Sep 17 00:00:00 2001 From: Jasper Zonneveld Date: Tue, 12 Mar 2024 16:59:39 +0100 Subject: [PATCH] test: add integration testsuite --- .github/workflows/tests.yml | 2 +- composer.json | 2 +- phpunit.xml.dist | 6 ++- tests/Integration/SituationsTest.php | 60 ++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 tests/Integration/SituationsTest.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ecebfa0..3fec4b2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,7 +43,7 @@ jobs: run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests - run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + run: XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite=default --coverage-text --coverage-clover=coverage.clover - name: Upload Scrutinizer coverage uses: sudo-bot/action-scrutinizer@latest diff --git a/composer.json b/composer.json index 2cf0824..2e1243d 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ } }, "scripts": { - "test": "phpunit", + "test": "phpunit --testsuite=default", "check-style": "php-cs-fixer fix --dry-run -v", "fix-style": "php-cs-fixer fix" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1111ad9..8b96ae0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,8 +22,12 @@ - + tests + tests/Integration + + + tests/Integration diff --git a/tests/Integration/SituationsTest.php b/tests/Integration/SituationsTest.php new file mode 100644 index 0000000..7292820 --- /dev/null +++ b/tests/Integration/SituationsTest.php @@ -0,0 +1,60 @@ +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; + } +}