From 2ab0b949ecd14cd0e4584d426e1dcf3c25876d88 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 30 Nov 2020 21:56:25 +0000 Subject: [PATCH 1/6] Enable PHP 8.0 --- .gitignore | 1 + .travis.yml | 3 +- Makefile | 16 +++++++-- composer.json | 6 ++-- depfile.yml => depfile.yaml | 0 phpunit.xml.dist | 42 +++++++++------------- tests/PhpDocumentor/Fixtures/Discworld.php | 5 +++ tests/TestCase/TestDoubles/PhpunitTest.php | 3 +- 8 files changed, 42 insertions(+), 34 deletions(-) rename depfile.yml => depfile.yaml (100%) diff --git a/.gitignore b/.gitignore index 2cdfb2d..8237495 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /composer.lock /vendor/ /.php_cs.cache +/.deptrac.cache .phpunit.result.cache diff --git a/.travis.yml b/.travis.yml index 8acb904..bb35d8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,8 @@ matrix: - php: 7.3 env: EXECUTE_DEPLOYMENT=true - php: 7.4 - - php: 7.4 + - php: 8.0 + - php: 8.0 env: deps=low fast_finish: true before_install: diff --git a/Makefile b/Makefile index 0698c78..dc2acce 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +IS_PHP8:=$(shell php -r 'echo (int)version_compare(PHP_VERSION, "8.0", ">=");') + default: build build: install test @@ -29,13 +31,21 @@ test-package: package test-package-tools cd tests/phar && ./tools/phpunit .PHONY: test-package +ifeq ($(IS_PHP8),1) +cs: +else cs: tools/php-cs-fixer PHP_CS_FIXER_IGNORE_ENV=1 tools/php-cs-fixer --dry-run --allow-risky=yes --no-interaction --ansi fix +endif .PHONY: cs +ifeq ($(IS_PHP8),1) +cs-fix: +else cs-fix: tools/php-cs-fixer PHP_CS_FIXER_IGNORE_ENV=1 tools/php-cs-fixer --allow-risky=yes --no-interaction --ansi fix .PHONY: cs-fix +endif deptrac: tools/deptrac tools/deptrac --no-interaction --ansi --formatter-graphviz-display=0 @@ -94,13 +104,13 @@ tools/php-cs-fixer: curl -Ls http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o tools/php-cs-fixer && chmod +x tools/php-cs-fixer tools/deptrac: - curl -Ls http://get.sensiolabs.de/deptrac.phar -o tools/deptrac && chmod +x tools/deptrac + curl -Ls https://github.com/sensiolabs-de/deptrac/releases/download/0.10.0/deptrac.phar -o tools/deptrac && chmod +x tools/deptrac tools/infection: tools/infection.pubkey - curl -Ls https://github.com/infection/infection/releases/download/0.16.1/infection.phar -o tools/infection && chmod +x tools/infection + curl -Ls https://github.com/infection/infection/releases/download/0.20.2/infection.phar -o tools/infection && chmod +x tools/infection tools/infection.pubkey: - curl -Ls https://github.com/infection/infection/releases/download/0.16.1/infection.phar.pubkey -o tools/infection.pubkey + curl -Ls https://github.com/infection/infection/releases/download/0.20.2/infection.phar.pubkey -o tools/infection.pubkey tools/box: curl -Ls https://github.com/humbug/box/releases/download/3.9.1/box.phar -o tools/box && chmod +x tools/box diff --git a/composer.json b/composer.json index 9d11438..10b063b 100644 --- a/composer.json +++ b/composer.json @@ -3,9 +3,9 @@ "description": "Initialises test doubles in PHPUnit test cases for you", "type": "library", "require": { - "php": "^7.3,<8.0", - "phpunit/phpunit": "^9.1", - "phpdocumentor/reflection-docblock": "^4.0.1" + "php": "^7.3 || ~8.0.0", + "phpunit/phpunit": "^9.0", + "phpdocumentor/reflection-docblock": "^5.2" }, "require-dev": { "phpspec/prophecy-phpunit": "dev-master" diff --git a/depfile.yml b/depfile.yaml similarity index 100% rename from depfile.yml rename to depfile.yaml diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 22eeb83..4799b74 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,19 @@ - - - - - tests - tests/phar - - - - - - src - - - - - - - + + + + src + + + + + + + + + tests + tests/phar + + + diff --git a/tests/PhpDocumentor/Fixtures/Discworld.php b/tests/PhpDocumentor/Fixtures/Discworld.php index b41f54b..0548846 100644 --- a/tests/PhpDocumentor/Fixtures/Discworld.php +++ b/tests/PhpDocumentor/Fixtures/Discworld.php @@ -17,4 +17,9 @@ class Discworld extends World private $detritus; private $notDocumented; + + /** + * Property with no var tag. + */ + private $noVarTag; } diff --git a/tests/TestCase/TestDoubles/PhpunitTest.php b/tests/TestCase/TestDoubles/PhpunitTest.php index 39a2d39..0d595f5 100644 --- a/tests/TestCase/TestDoubles/PhpunitTest.php +++ b/tests/TestCase/TestDoubles/PhpunitTest.php @@ -49,8 +49,7 @@ public function test_mock_objects_verify_expectations() { $discworld = new Discworld($this->vimes, [$this->nobby, $this->fred]); - $this->vimes->expects($this->at(0))->method('recruit')->with($this->nobby); - $this->vimes->expects($this->at(1))->method('recruit')->with($this->fred); + $this->vimes->expects($this->exactly(2))->method('recruit')->withConsecutive([$this->nobby], [$this->fred]); $discworld->createNightWatch(); } From 0e9aafb6a607c66839365098c24a4abdac317433 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 30 Nov 2020 22:00:04 +0000 Subject: [PATCH 2/6] Drop support for PHP 7.3 --- .travis.yml | 3 +-- Makefile | 2 +- composer.json | 2 +- manifest.xml.in | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb35d8f..15a4d3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ language: php matrix: include: - - php: 7.3 - env: EXECUTE_DEPLOYMENT=true - php: 7.4 + env: EXECUTE_DEPLOYMENT=true - php: 8.0 - php: 8.0 env: deps=low diff --git a/Makefile b/Makefile index dc2acce..ad5317a 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ package: tools/box cd build/phar && \ composer remove phpunit/phpunit --no-update && \ - composer config platform.php 7.3 && \ + composer config platform.php 7.4 && \ composer update --no-dev -o -a tools/box compile diff --git a/composer.json b/composer.json index 10b063b..2c3674d 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Initialises test doubles in PHPUnit test cases for you", "type": "library", "require": { - "php": "^7.3 || ~8.0.0", + "php": "^7.4 || ~8.0.0", "phpunit/phpunit": "^9.0", "phpdocumentor/reflection-docblock": "^5.2" }, diff --git a/manifest.xml.in b/manifest.xml.in index dd7e0c6..09e4cfc 100644 --- a/manifest.xml.in +++ b/manifest.xml.in @@ -1,7 +1,7 @@ - + @@ -10,6 +10,6 @@ - + From 40d70d21e3ab9f9fec473369d68bfdc7f8758fc5 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 30 Nov 2020 22:07:47 +0000 Subject: [PATCH 3/6] Migrate from Travis to Github Actions --- .github/workflows/build.yml | 69 +++++++++++++++++++++++++++++++++++++ .travis.yml | 26 -------------- 2 files changed, 69 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5331963 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,69 @@ +name: Build + +on: + push: + branches: [master] + pull_request: + release: + types: [created] + schedule: + - cron: '0 4 * * *' + +jobs: + tests: + runs-on: ubuntu-latest + name: Build and test + strategy: + matrix: + php: [7.4, 8.0] + deps: [high] + include: + - php: 8.0 + deps: low + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + ini-values: "phar.readonly=0" + + - name: Test & package + if: matrix.deps == 'high' + run: make update test package test-package + + - name: Test & package (low) + if: matrix.deps == 'low' + run: make update-min test-min package test-package + + - name: Upload the phar + uses: actions/upload-artifact@v1 + if: matrix.php == '7.4' && matrix.deps == 'high' + with: + name: zalas-phpunit-doubles-extension.phar + path: build/zalas-phpunit-doubles-extension.phar + + publish-phars: + runs-on: ubuntu-latest + name: Publish PHARs + needs: tests + if: github.event_name == 'release' + steps: + - name: Download the phar + uses: actions/download-artifact@v1 + with: + name: zalas-phpunit-doubles-extension.phar + path: . + - name: Release the phar + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./zalas-phpunit-doubles-extension.phar + asset_name: zalas-phpunit-doubles-extension.phar + asset_content_type: application/zip diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 15a4d3d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: php -matrix: - include: - - php: 7.4 - env: EXECUTE_DEPLOYMENT=true - - php: 8.0 - - php: 8.0 - env: deps=low - fast_finish: true -before_install: -- phpenv config-rm xdebug.ini || echo "XDebug is not enabled" -install: -- if [[ $deps = low ]]; then make update-min; else make install; fi -script: -- if [[ $deps = low ]]; then make test-min; else make test; fi -- make package test-package -deploy: - provider: releases - api_key: - secure: SSjBKEch3qcKlWVEb5DbXDFUvdnLTV03e82OryeNIYPD7pWhjoxdOWicB/od9b39/YD/LR1lxMt9+fHRseCrwo1FOUZmnMgzphr0MiF2RZUF4CpWFJXL+EbxQ/GbKVv+hQhDwyBDwlNchPzrVM3tRe/llt0Xg8A7NGQI0UBdZZFJKWgydoSYN4VSias8FTBMS0Nvi/D4cE2iHDJE1bDpx+Fm1w9LP/DfvnSMcQwJ1mwTNiIRO0/vH5OWlkwWjT2UDEP3TOe9sj6XfYHpU9nuaCEGTiL3XUnfWyNP8hk5Fq8wsN0vBSvW66kmz2uDnN7vZPm7b7YUXfTHJW7M78DzWmfSjaiNFx35yjgJ34tIDxfv00BOh5t2OGXEt4qX8Si0oDkFpotnCk+zdQM8IaCYyITRa1/gtjyAZLW8yvBE9l5ZW51mEURCK94Gm22T+wo4srLtZqqho0yzaFVKxGzQ11HC0KskoMR4zE9P3C9p2PDQO+o2GFSr9o8hlj0QvYVpyyfBG95y8fUyIddJropfkyXuR1Ze4clmNJN/PmKG6pzSZzOM2gBIXUNlZ1BZcPo4J1QvWsvqkkYLH908VOWShrPQlSGUmtS+FSfO4zDFwnNmtScd/WHqZmSZi2ZA/dvJXhAB3sb4QBmbKqcQArUPvBiasrFCqhn/uenrQMKNudg= - file: build/zalas-phpunit-doubles-extension.phar - skip_cleanup: true - on: - tags: true - repo: jakzal/phpunit-doubles - condition: "$EXECUTE_DEPLOYMENT" From e22ec3d56b02bcbd5ea5631d41f42db617afa0ad Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 30 Nov 2020 22:19:43 +0000 Subject: [PATCH 4/6] Define conflict with phpdocumentor/type-resolver 1.3.0 --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 2c3674d..712e472 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,9 @@ "require-dev": { "phpspec/prophecy-phpunit": "dev-master" }, + "conflict": { + "phpdocumentor/type-resolver": "1.3.0" + }, "autoload": { "psr-4": { "Zalas\\PHPUnit\\Doubles\\": "src" From ef9b333b8e991cf5ac98996c2094bf9723a85536 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 30 Nov 2020 22:25:40 +0000 Subject: [PATCH 5/6] Update box to 3.10.0 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ad5317a..ee1a851 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ tools/infection.pubkey: curl -Ls https://github.com/infection/infection/releases/download/0.20.2/infection.phar.pubkey -o tools/infection.pubkey tools/box: - curl -Ls https://github.com/humbug/box/releases/download/3.9.1/box.phar -o tools/box && chmod +x tools/box + curl -Ls https://github.com/humbug/box/releases/download/3.10.0/box.phar -o tools/box && chmod +x tools/box tests/phar/tools/phpunit: curl -Ls https://phar.phpunit.de/phpunit-9.phar -o tests/phar/tools/phpunit && chmod +x tests/phar/tools/phpunit From 870b3dd96d546849d272e2c255d16a5bfeeb2468 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 30 Nov 2020 22:27:39 +0000 Subject: [PATCH 6/6] Disable packaging on PHP 8 until box supports it --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index ee1a851..f0941b4 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,12 @@ test: vendor cs deptrac phpunit infection test-min: update-min cs deptrac phpunit infection .PHONY: test-min +ifeq ($(IS_PHP8),1) +test-package: +else test-package: package test-package-tools cd tests/phar && ./tools/phpunit +endif .PHONY: test-package ifeq ($(IS_PHP8),1) @@ -76,6 +80,9 @@ clean: find tests/phar/tools -not -path '*/\.*' -type f -delete .PHONY: clean +ifeq ($(IS_PHP8),1) +package: +else package: tools/box $(eval VERSION=$(shell (git describe --abbrev=0 --tags 2>/dev/null || echo "0.1-dev") | sed -e 's/^v//')) @rm -rf build/phar && mkdir -p build/phar @@ -91,6 +98,7 @@ package: tools/box tools/box compile @rm -rf build/phar +endif .PHONY: package vendor: install