From 64eb2a7f68e0c493494f9fcaa43337cdde38559f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Aug 2023 14:30:48 +0200 Subject: [PATCH 1/3] BaseTestCase: Use Icinga Web's base test case --- library/Businessprocess/Test/BaseTestCase.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/library/Businessprocess/Test/BaseTestCase.php b/library/Businessprocess/Test/BaseTestCase.php index 807905d..daab69c 100644 --- a/library/Businessprocess/Test/BaseTestCase.php +++ b/library/Businessprocess/Test/BaseTestCase.php @@ -7,21 +7,21 @@ use Icinga\Application\ApplicationBootstrap; use Icinga\Application\Icinga; use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\Storage\LegacyStorage; -use Icinga\Module\Businessprocess\Web\FakeRequest; -use PHPUnit_Framework_TestCase; -abstract class BaseTestCase extends PHPUnit_Framework_TestCase +abstract class BaseTestCase extends \Icinga\Test\BaseTestCase { /** @var ApplicationBootstrap */ private static $app; - /** - * @inheritdoc - */ - public function setUp() + public function setUp(): void { - $this->app(); - FakeRequest::setConfiguredBaseUrl('/icingaweb2/'); + parent::setUp(); + + $this->getRequestMock()->shouldReceive('getBaseUrl')->andReturn('/icingaweb2/'); + + $this->app() + ->getModuleManager() + ->loadModule('businessprocess'); } protected function emptyConfigSection() From 1b074b523681521a102d947177ddb301c41c66c5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Aug 2023 14:32:50 +0200 Subject: [PATCH 2/3] php: Add test job --- .github/workflows/php.yml | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 06acb02..45fc836 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -40,3 +40,46 @@ jobs: - name: PHP CodeSniffer if: success() || matrix.allow_failure run: phpcs + + test: + name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + env: + phpunit-version: 8.5 + + strategy: + fail-fast: false + matrix: + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + os: ['ubuntu-latest'] + + steps: + - name: Checkout code base + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: phpunit:${{ matrix.phpunit-version || env.phpunit-version }} + + - name: Setup Icinga Web + run: | + git clone --depth 1 https://github.com/Icinga/icingaweb2.git _icingaweb2 + ln -s `pwd` _icingaweb2/modules/businessprocess + + - name: Setup Libraries + run: | + mkdir _libraries + git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git _libraries/ipl + git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git _libraries/vendor + + - name: Setup dependencies + run: composer require -d _icingaweb2 -n --no-progress mockery/mockery + + - name: PHPUnit + env: + ICINGAWEB_LIBDIR: _libraries + ICINGAWEB_CONFIGDIR: test/config + run: phpunit --verbose --bootstrap _icingaweb2/test/php/bootstrap.php From dc41ded97e428cb95d3aef36903c5c8aeedcc1d2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Aug 2023 14:35:29 +0200 Subject: [PATCH 3/3] Drop unused integration configs --- .gitlab-ci.yml | 86 -------------------------------------------------- .travis.yml | 31 ------------------ phpunit.xml | 1 - 3 files changed, 118 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100644 .travis.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index aed4be7..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,86 +0,0 @@ -stages: -- Coding Standards -- Unit-Tests -- Build Packages - -variables: - BASE_VERSION: "2.0.0" - VERSION_SUFFIX: "-b${CI_BUILD_ID}-${CI_BUILD_REF_SLUG}" - -PSR2 CS Test: - stage: Coding Standards - tags: - - xenial - script: - - phpcs --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Businessprocess/ application/ configuration.php run.php test - -Ubuntu Xenial: - stage: Unit-Tests - tags: - - xenial - - businessprocess - script: - - phpunit --testdox --coverage-html=coverage || phpunit --verbose - artifacts: - expire_in: 1 week - name: code-coverage - paths: - - coverage/* - -Debian Jessie: - stage: Unit-Tests - tags: - - jessie - - businessprocess - script: - - phpunit --testdox || phpunit --verbose - -CentOS 6: - stage: Unit-Tests - tags: - - centos6 - - businessprocess - script: - - phpunit --testdox || phpunit --verbose - -CentOS 7: - stage: Unit-Tests - tags: - - centos7 - - businessprocess - script: - - phpunit --testdox || phpunit --verbose - -Xenial Packages: - stage: Build Packages - tags: - - xenial - - businessprocess - script: - - cp -a packaging/debian debian - - dch --no-conf -U -M --empty -v "${BASE_VERSION}${VERSION_SUFFIX}-${CI_BUILD_REF:0:7}" "Automated build triggered by ${GITLAB_USER_ID} <${GITLAB_USER_EMAIL}>" - - cp LICENSE debian/copyright - - dpkg-buildpackage -us -uc - - mkdir build - - mv ../icingaweb2-module-businessprocess*.deb build/ - artifacts: - expire_in: 1 week - paths: - - build/* - -Jessie Packages: - stage: Build Packages - tags: - - jessie - - businessprocess - script: - - cp -a packaging/debian debian - - dch --no-conf -U -M --empty -v "${BASE_VERSION}${VERSION_SUFFIX}-${CI_BUILD_REF:0:7}" "Automated build triggered by ${GITLAB_USER_ID} <${GITLAB_USER_EMAIL}>" - - cp LICENSE debian/copyright - - dpkg-buildpackage -us -uc - - mkdir build - - mv ../icingaweb2-module-businessprocess*.deb build/ - artifacts: - expire_in: 1 week - paths: - - build/* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 69749bb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: php -php: - - '5.4' - - '5.5' - - '5.6' - - '7.0' - - '7.1' - - '7.2' - - nightly - -matrix: - fast_finish: true - allow_failures: - - php: '5.4' - - php: '5.5' - - php: nightly - -cache: - directories: - - vendor - -env: - - ICINGAWEB_VERSION=2.6.2 - - IPL_VERSION=0.1.1 - -before_script: - - ./test/setup_vendor.sh - -script: - - php vendor/phpcs.phar - - php vendor/phpunit.phar --testdox || php vendor/phpunit.phar --verbose diff --git a/phpunit.xml b/phpunit.xml index 064e01c..5eaf639 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="test/bootstrap.php" >