From 07d9145caab3305c106a5f697e9d26c9d2c50027 Mon Sep 17 00:00:00 2001 From: Matthias Glaub Date: Wed, 11 Aug 2021 20:20:57 +0200 Subject: [PATCH 1/3] raise phpunit version --- composer.json | 4 ++-- .../Application/MaglLegacyTest.php | 4 ++-- .../Controller/LegacyControllerTest.php | 2 +- tests/MaglLegacyApplicationTest/ModuleTest.php | 6 +++--- .../Options/LegacyControllerOptionsTest.php | 4 ++-- .../Service/ControllerServiceTest.php | 10 ++++++---- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 8fc1b63..4abf2e3 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ } ], "require": { - "php": "^7.0", + "php": "^7.3 || ^8.0", "laminas/laminas-eventmanager": "^3.0", "laminas/laminas-http": "^2.0", "laminas/laminas-mvc": "^3.0", @@ -33,7 +33,7 @@ "require-dev": { "laminas/laminas-modulemanager": "^2.5", "laminas/laminas-test": "^3.0", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^9" }, "autoload": { "psr-4": { diff --git a/tests/MaglLegacyApplicationTest/Application/MaglLegacyTest.php b/tests/MaglLegacyApplicationTest/Application/MaglLegacyTest.php index dd9c562..ba523e8 100644 --- a/tests/MaglLegacyApplicationTest/Application/MaglLegacyTest.php +++ b/tests/MaglLegacyApplicationTest/Application/MaglLegacyTest.php @@ -8,9 +8,9 @@ namespace MaglLegacyApplicationTest\Application; use MaglLegacyApplication\Application\MaglLegacy; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; -class MaglLegacyTest extends PHPUnit_Framework_TestCase +class MaglLegacyTest extends TestCase { public function testGetInstance() diff --git a/tests/MaglLegacyApplicationTest/Controller/LegacyControllerTest.php b/tests/MaglLegacyApplicationTest/Controller/LegacyControllerTest.php index 02c51a8..ffca7f2 100644 --- a/tests/MaglLegacyApplicationTest/Controller/LegacyControllerTest.php +++ b/tests/MaglLegacyApplicationTest/Controller/LegacyControllerTest.php @@ -15,7 +15,7 @@ class LegacyControllerTest extends AbstractHttpControllerTestCase protected $traceError = true; - public function setUp() + public function setUp(): void { $sm = \MaglLegacyApplicationTest\Bootstrap::getServiceManager(); $this->setApplicationConfig($sm->get('ApplicationConfig')); diff --git a/tests/MaglLegacyApplicationTest/ModuleTest.php b/tests/MaglLegacyApplicationTest/ModuleTest.php index 464325f..be5f790 100644 --- a/tests/MaglLegacyApplicationTest/ModuleTest.php +++ b/tests/MaglLegacyApplicationTest/ModuleTest.php @@ -3,14 +3,14 @@ namespace MaglLegacyApplicationTest; use MaglLegacyApplication\Module; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; /** * Description of ModuleTest * * @author matthias */ -class ModuleTest extends PHPUnit_Framework_TestCase +class ModuleTest extends TestCase { /** @@ -19,7 +19,7 @@ class ModuleTest extends PHPUnit_Framework_TestCase */ private $instance; - public function setUp() + public function setUp(): void { $this->instance = new Module(); } diff --git a/tests/MaglLegacyApplicationTest/Options/LegacyControllerOptionsTest.php b/tests/MaglLegacyApplicationTest/Options/LegacyControllerOptionsTest.php index 2857fc8..50d8200 100644 --- a/tests/MaglLegacyApplicationTest/Options/LegacyControllerOptionsTest.php +++ b/tests/MaglLegacyApplicationTest/Options/LegacyControllerOptionsTest.php @@ -7,9 +7,9 @@ namespace MaglLegacyApplicationTest\Options; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; -class LegacyControllerOptionsTest extends PHPUnit_Framework_TestCase +class LegacyControllerOptionsTest extends TestCase { public function testSetGetDocRoot() diff --git a/tests/MaglLegacyApplicationTest/Service/ControllerServiceTest.php b/tests/MaglLegacyApplicationTest/Service/ControllerServiceTest.php index dde3714..d3c3a5d 100644 --- a/tests/MaglLegacyApplicationTest/Service/ControllerServiceTest.php +++ b/tests/MaglLegacyApplicationTest/Service/ControllerServiceTest.php @@ -8,14 +8,15 @@ namespace MaglLegacyApplicationTest\Service; +use Laminas\Http\Response; use Laminas\Mvc\Controller\AbstractActionController; use Laminas\Mvc\Controller\ControllerManager; use Laminas\View\Model\ViewModel; use MaglLegacyApplication\Service\ControllerService; use MaglLegacyApplicationTest\Bootstrap; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; -class ControllerServiceTest extends PHPUnit_Framework_TestCase +class ControllerServiceTest extends TestCase { /** @@ -23,7 +24,7 @@ class ControllerServiceTest extends PHPUnit_Framework_TestCase */ private $instance; - public function setUp() + public function setUp(): void { $this->instance = Bootstrap::getServiceManager()->get('MaglControllerService'); } @@ -38,7 +39,8 @@ public function testRunControllerAction() /** @var ControllerManager $controllerManager */ $controllerManager = Bootstrap::getServiceManager()->get('ControllerManager'); $controllerManager->setService('TestController', new TestController()); - $this->instance->runControllerAction('TestController', 'test'); + $response = $this->instance->runControllerAction('TestController', 'test'); + $this->assertInstanceOf(Response::class, $response); } } From f169977e9bc5d52eb3d104b8b87dd28cd6374b2f Mon Sep 17 00:00:00 2001 From: Matthias Glaub Date: Wed, 11 Aug 2021 20:21:20 +0200 Subject: [PATCH 2/3] switch to github actions --- .github/workflows/unit-tests.yml | 50 ++++++++++++++++++++++++++++++++ .scrutinizer.yml | 8 ----- .travis.yml | 23 --------------- 3 files changed, 50 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/unit-tests.yml delete mode 100644 .scrutinizer.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..ef76d9a --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,50 @@ +name: unit-tests + +on: [push] + +jobs: + phpunit: + name: "PHPUnit tests" + + runs-on: ${{ matrix.operating-system }} + + strategy: + matrix: + php-version: + - "7.3" + - "7.4" + - "8.0" + operating-system: + - "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "pcov" + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + + - name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + restore-keys: | + composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}- + composer-${{ runner.os }}-${{ matrix.php-version }}- + composer-${{ runner.os }}- + composer- + - name: "Install dependencies" + run: "composer update --no-interaction --no-progress --no-suggest" + + - name: "Tests" + run: "vendor/bin/phpunit -c tests" + diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 604f13a..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,8 +0,0 @@ -imports: - - php - -tools: - external_code_coverage: true - php_code_sniffer: - config: - ruleset: PSR2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index abd453c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -matrix: - fast_finish: true - include: - - php: 7.0 - - php: 7.1 - - php: 7.2 - - php: 7.3 - env: - - EXECUTE_SCRUTINIZER=true - - XDEBUG_MODE=coverage - -before_script: - - if [ -z "$PREFER_LOWEST" ]; then composer update --no-interaction; fi - - if [ "$PREFER_LOWEST" == 'true' ]; then composer update --no-interaction --prefer-lowest; fi - -script: - - vendor/bin/phpunit -c tests - -after_script: - - if [[ $EXECUTE_SCRUTINIZER == 'true' ]]; then wget https://scrutinizer-ci.com/ocular.phar || return 0 ; fi - - if [[ $EXECUTE_SCRUTINIZER == 'true' ]]; then php ocular.phar code-coverage:upload --format=php-clover tests/log/coverage.xml || return 0 ; fi From 84b33a410998e104b8f84eb3f21774754aba61d4 Mon Sep 17 00:00:00 2001 From: Matthias Glaub Date: Wed, 11 Aug 2021 20:50:53 +0200 Subject: [PATCH 3/3] ignore platform reqs for php 8.0 (just testing for now) --- .github/workflows/unit-tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index ef76d9a..694978a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -43,7 +43,11 @@ jobs: composer-${{ runner.os }}- composer- - name: "Install dependencies" + if: ${{ matrix.php-version != '8.0' }} run: "composer update --no-interaction --no-progress --no-suggest" + - name: "Install dependencies --ignore-platform-reqs" + if: ${{ matrix.php-version == '8.0' }} + run: "composer update --ignore-platform-reqs --no-interaction --no-progress --no-suggest" - name: "Tests" run: "vendor/bin/phpunit -c tests"