Skip to content

Commit

Permalink
Merge pull request #1059 from davedevelopment/drop-old-php-and-phpunit
Browse files Browse the repository at this point in the history
Drop support for PHP < 7.3 and PHPUnit < 8
  • Loading branch information
davedevelopment committed May 15, 2020
2 parents 8cfe26b + 2a563da commit 480facc
Show file tree
Hide file tree
Showing 40 changed files with 110 additions and 1,300 deletions.
47 changes: 2 additions & 45 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,6 @@ matrix:
- php: nightly
fast_finish: true
include:
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=latest
- php: 5.6
env:
- PHPUNIT=minimum
- DEPS=latest
- php: 7.0
env:
- DEPS=lowest
- php: 7.0
env:
- DEPS=latest
- php: 7.1
env:
- DEPS=lowest
- php: 7.1
env:
- DEPS=latest
- php: 7.2
env:
- DEPS=lowest
- php: 7.2
env:
- DEPS=latest
- php: 7.3
env:
- DEPS=lowest
Expand All @@ -55,27 +27,12 @@ matrix:
- COMPOSER_FLAGS="--ignore-platform-reqs"

install:
- if [[ $PHPUNIT == 'minimum' ]]; then sed -i 's/~5.7|/5.4.*|/g' ./composer.json ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update --no-interaction $COMPOSER_FLAGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable --no-interaction $COMPOSER_FLAGS ; fi

before_script:
# Install extensions for PHP 5.x series. 7.x includes them by default.
- |
if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then
cat <<< '
extension=mongo.so
extension=redis.so
' >> ~/.phpenv/versions/"$(phpenv version-name)"/etc/conf.d/travis.ini
fi
script:
- |
if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then
./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite PHP56";
else
./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite";
fi
./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite";
after_success:
- composer require satooshi/php-coveralls
Expand All @@ -100,5 +57,5 @@ deploy:
github_token: $GITHUB_TOKEN
on:
branch: master
php: '7.1'
php: '7.3'
condition: $DEPS = latest
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Change Log

## 1.3.2 (XXXX-XX-XX)
## 1.4.0 (XXXX-XX-XX)

* Fix andAnyOthers() to properly match earlier expectations (#1051)
* Drops support for PHP < 7.3 and PHPUnit < 8

## 1.3.1 (2019-12-26)
* Revert improved exception debugging due to BC breaks (#1032)
Expand Down
51 changes: 1 addition & 50 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ docs/api/index.html: vendor/composer/installed.json $(library_files) phpDocument
php phpDocumentor.phar run -d library -t docs/api

.PHONY: test-all
test-all: test-74 test-73 test-72 test-71 test-70 test-56

.PHONY: test-all-7
test-all-7: test-74 test-73 test test-71 test-70
test-all: test-74 test-73

.PHONY: test-74
test-74: deps
Expand All @@ -32,49 +29,3 @@ test-74: deps
.PHONY: test-73
test-73: deps
docker run -it --rm -v "$$PWD":/opt/mockery -w /opt/mockery php:7.3-cli php vendor/bin/phpunit

.PHONY: test-72
test-72: deps
docker run -it --rm -v "$$PWD":/opt/mockery -w /opt/mockery php:7.2-cli php vendor/bin/phpunit

.PHONY: test-71
test-71: build71
docker run -it --rm \
-v "$$PWD/library":/opt/mockery/library \
-v "$$PWD/tests":/opt/mockery/tests \
-v "$$PWD/phpunit.xml.dist":/opt/mockery/phpunit.xml \
-w /opt/mockery \
mockery_php71 \
php vendor/bin/phpunit

.PHONY: build71
build71:
docker build -t mockery_php71 -f "$$PWD/docker/php71/Dockerfile" .

.PHONY: test-70
test-70: build70
docker run -it --rm \
-v "$$PWD/library":/opt/mockery/library \
-v "$$PWD/tests":/opt/mockery/tests \
-v "$$PWD/phpunit.xml.dist":/opt/mockery/phpunit.xml \
-w /opt/mockery \
mockery_php70 \
php vendor/bin/phpunit

.PHONY: build70
build70:
docker build -t mockery_php70 -f "$$PWD/docker/php70/Dockerfile" .

.PHONY: test-56
test-56: build56
docker run -it --rm \
-v "$$PWD/library":/opt/mockery/library \
-v "$$PWD/tests":/opt/mockery/tests \
-v "$$PWD/phpunit.xml.dist":/opt/mockery/phpunit.xml \
-w /opt/mockery \
mockery_php56 \
php vendor/bin/phpunit

.PHONY: build56
build56:
docker build -t mockery_php56 -f "$$PWD/docker/php56/Dockerfile" .
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
}
],
"require": {
"php": ">=5.6.0",
"php": "^7.3.0",
"lib-pcre": ">=7.0",
"hamcrest/hamcrest-php": "~2.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7.10|~6.5|~7.0|~8.0|~9.0"
"phpunit/phpunit": "^8.0.0 || ^9.0.0"
},
"conflict": {
"phpunit/phpunit": "<8.0"
},
"autoload": {
"psr-0": {
Expand All @@ -50,7 +53,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
"dev-master": "1.4.x-dev"
}
}
}
14 changes: 0 additions & 14 deletions docker/php56/Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions docker/php70/Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions docker/php71/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions docs/reference/phpunit_integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ Make sure Composer's or Mockery's autoloader is present in the bootstrap file
or we will need to also define a "file" attribute pointing to the file of the
``TestListener`` class.

.. caution::

The ``TestListener`` will only work for PHPUnit 6+ versions.

For PHPUnit versions 5 and lower, the test listener does not work.

If we are creating the test suite programmatically we may add the listener
like this:

Expand Down
48 changes: 21 additions & 27 deletions library/Mockery.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,18 @@ public static function globalHelpers()
public static function builtInTypes()
{
$builtInTypes = array(
'self',
'array',
'callable',
// Up to php 7
'bool',
'callable',
'float',
'int',
'string',
'iterable',
'object',
'self',
'string',
'void',
);

if (version_compare(PHP_VERSION, '7.2.0-dev') >= 0) {
$builtInTypes[] = 'object';
}

return $builtInTypes;
}

Expand Down Expand Up @@ -858,29 +854,27 @@ private static function getNewDemeterMock(
) {
$newMockName = 'demeter_' . md5($parent) . '_' . $method;

if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
$parRef = null;
$parRefMethod = null;
$parRefMethodRetType = null;
$parRef = null;
$parRefMethod = null;
$parRefMethodRetType = null;

$parentMock = $exp->getMock();
if ($parentMock !== null) {
$parRef = new ReflectionObject($parentMock);
}
$parentMock = $exp->getMock();
if ($parentMock !== null) {
$parRef = new ReflectionObject($parentMock);
}

if ($parRef !== null && $parRef->hasMethod($method)) {
$parRefMethod = $parRef->getMethod($method);
$parRefMethodRetType = $parRefMethod->getReturnType();
if ($parRef !== null && $parRef->hasMethod($method)) {
$parRefMethod = $parRef->getMethod($method);
$parRefMethodRetType = $parRefMethod->getReturnType();

if ($parRefMethodRetType !== null) {
$nameBuilder = new MockNameBuilder();
$nameBuilder->addPart('\\' . $newMockName);
$type = PHP_VERSION_ID >= 70100 ? $parRefMethodRetType->getName() : (string)$parRefMethodRetType;
$mock = self::namedMock($nameBuilder->build(), $type);
$exp->andReturn($mock);
if ($parRefMethodRetType !== null) {
$nameBuilder = new MockNameBuilder();
$nameBuilder->addPart('\\' . $newMockName);
$type = $parRefMethodRetType->getName();
$mock = self::namedMock($nameBuilder->build(), $type);
$exp->andReturn($mock);

return $mock;
}
return $mock;
}
}

Expand Down
47 changes: 0 additions & 47 deletions library/Mockery/Adapter/Phpunit/Legacy/TestListenerForV5.php

This file was deleted.

0 comments on commit 480facc

Please sign in to comment.