Skip to content

Commit

Permalink
Merge pull request #17 from jakzal/php-8.0
Browse files Browse the repository at this point in the history
Enable PHP 8.0 and drop PHP 7.3
  • Loading branch information
jakzal committed Nov 30, 2020
2 parents fd32924 + 870b3dd commit c1eb916
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 63 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/composer.lock
/vendor/
/.php_cs.cache
/.deptrac.cache
.phpunit.result.cache
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

28 changes: 23 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
IS_PHP8:=$(shell php -r 'echo (int)version_compare(PHP_VERSION, "8.0", ">=");')

default: build

build: install test
Expand Down Expand Up @@ -25,17 +27,29 @@ 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)
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
Expand Down Expand Up @@ -66,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
Expand All @@ -75,12 +92,13 @@ 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

@rm -rf build/phar
endif
.PHONY: package

vendor: install
Expand All @@ -94,16 +112,16 @@ 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
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
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
"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.4 || ~8.0.0",
"phpunit/phpunit": "^9.0",
"phpdocumentor/reflection-docblock": "^5.2"
},
"require-dev": {
"phpspec/prophecy-phpunit": "dev-master"
},
"conflict": {
"phpdocumentor/type-resolver": "1.3.0"
},
"autoload": {
"psr-4": {
"Zalas\\PHPUnit\\Doubles\\": "src"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions manifest.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
<contains name="zalas/phpunit-doubles" version="@@version@@" type="extension">
<extension for="phpunit/phpunit" compatible="^9.1"/>
<extension for="phpunit/phpunit" compatible="^9.0"/>
</contains>

<copyright>
Expand All @@ -10,6 +10,6 @@
</copyright>

<requires>
<php version="^7.3"/>
<php version="^7.4"/>
</requires>
</phar>
42 changes: 17 additions & 25 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
verbose="true">

<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
<exclude>tests/phar</exclude>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-html" target="build/coverage" lowUpperBound="50" highLowerBound="95"/>
<log type="coverage-clover" target="build/coverage.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" colors="true" verbose="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="build/coverage.xml"/>
<html outputDirectory="build/coverage" lowUpperBound="50" highLowerBound="95"/>
</report>
</coverage>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
<exclude>tests/phar</exclude>
</testsuite>
</testsuites>
<logging/>
</phpunit>
5 changes: 5 additions & 0 deletions tests/PhpDocumentor/Fixtures/Discworld.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ class Discworld extends World
private $detritus;

private $notDocumented;

/**
* Property with no var tag.
*/
private $noVarTag;
}
3 changes: 1 addition & 2 deletions tests/TestCase/TestDoubles/PhpunitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit c1eb916

Please sign in to comment.