Skip to content

Commit

Permalink
Make tests run on PHP 7.3 (#22)
Browse files Browse the repository at this point in the history
* Ignore platform requirements on nightly PHP (want to test 7.3)

* bumping zend-config minimum, installing memcache in nightly

* Tests pass locally with --prefer-lowest, answering prompts in memcache install

* try memcached not memcache

* remove default response for memcached install

* answer no to first question

* different default

* sigh

* install libmemcached-dev

* try again

* giving up on memcached for now

* adding php 7.3 tag to travis

* Fixing some local php 7.3 issues

* temporarily using dev-master for a few dependencies

* testing dev-master for zend_session

* bumping travis php versions

* locking in some versions, adding a phpstan ignore that came up

* bumping phpunit version

* need new release of zf1-validate-file for tests to pass in phpunit 7
  • Loading branch information
jaydiablo authored Mar 5, 2019
1 parent 2233be4 commit eab45fd
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 44 deletions.
57 changes: 39 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@ language: php

sudo: false

php:
- 7
- 7.1
- 7.2
- nightly
cache:
directories:
- $HOME/.composer/cache
- vendor

env: TMPDIR=/tmp USE_XDEBUG=false
env:
global:
- COMPOSER_ARGS=""
- TMPDIR=/tmp
- USE_XDEBUG=false
- COMPOSER_DISCARD_CHANGES=1

stages:
- test
- phpstan analysis
- test with coverage

branches:
only:
master

before_install:
- travis_retry composer self-update

install:
- phpenv rehash
- travis_retry composer install --no-interaction --prefer-source
- travis_retry composer update --no-interaction --prefer-stable $COMPOSER_ARGS

services:
- memcached

stages:
- test
- phpstan analysis
- test with coverage

before_script:
- if [[ "$USE_XDEBUG" == false ]]; then phpenv config-rm xdebug.ini || return 0; fi
- phpenv config-add tests/travis.ini
Expand All @@ -48,16 +49,36 @@ script:
jobs:
fast_finish: true
allow_failures:
- php: 7.4snapshot
- php: nightly
include:
- php: 7.1
env: COMPOSER_ARGS="--prefer-lowest"
- php: 7.1
- php: 7.2
env: COMPOSER_ARGS="--prefer-lowest"
- php: 7.2
- php: 7.3
env: COMPOSER_ARGS="--prefer-lowest"
- php: 7.3
- php: 7.4snapshot
env: COMPOSER_ARGS="--ignore-platform-reqs --prefer-lowest"
- php: 7.4snapshot
env: COMPOSER_ARGS="--ignore-platform-reqs"
- php: nightly
env: COMPOSER_ARGS="--ignore-platform-reqs --prefer-lowest"
- php: nightly
env: COMPOSER_ARGS="--ignore-platform-reqs"

- stage: phpstan analysis
php: 7.1
php: 7.2
env: TMPDIR=/tmp USE_XDEBUG=false
script:
- ./bin/phpstan analyse -l 4 --autoload-file=vendor/autoload.php --memory-limit=1024M -c phpstan.neon ./library

- stage: test with coverage
php: 7.1
env: TMPDIR=/tmp USE_XDEBUG=true
php: 7.2
env: COMPOSER_ARGS="" TMPDIR=/tmp USE_XDEBUG=true
script:
- cd tests/
- php runalltests.php --coverage
Expand Down
28 changes: 14 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"diablomedia/zendframework1-auth-adapter-openid": "^1.0.0",
"diablomedia/zendframework1-cache": "^1.0.0",
"diablomedia/zendframework1-captcha": "^1.0.0",
"diablomedia/zendframework1-config": "^1.0.0",
"diablomedia/zendframework1-config": "^1.0.1",
"diablomedia/zendframework1-controller": "^1.0.0",
"diablomedia/zendframework1-controller-action-helper-ajaxcontext": "^1.0.0",
"diablomedia/zendframework1-controller-action-helper-autocomplete": "^1.0.0",
Expand All @@ -29,26 +29,26 @@
"diablomedia/zendframework1-crypt": "^1.0.0",
"diablomedia/zendframework1-currency": "^1.0.0",
"diablomedia/zendframework1-date": "^1.0.0",
"diablomedia/zendframework1-db": "^1.0.0",
"diablomedia/zendframework1-db": "^1.0.1",
"diablomedia/zendframework1-dojo": "^1.0.0",
"diablomedia/zendframework1-dom": "^1.0.0",
"diablomedia/zendframework1-eventmanager": "^1.0.0",
"diablomedia/zendframework1-exception": "^1.0.2",
"diablomedia/zendframework1-file": "^1.0.0",
"diablomedia/zendframework1-filter": "^1.0.0",
"diablomedia/zendframework1-filter-input": "^1.0.0",
"diablomedia/zendframework1-form": "^1.0.0",
"diablomedia/zendframework1-http": "^1.0.0",
"diablomedia/zendframework1-form": "^1.0.3",
"diablomedia/zendframework1-http": "^1.0.1",
"diablomedia/zendframework1-json": "^1.0.0",
"diablomedia/zendframework1-layout": "^1.0.0",
"diablomedia/zendframework1-ldap": "^1.0.0",
"diablomedia/zendframework1-loader": "^1.0.0",
"diablomedia/zendframework1-ldap": "^1.0.1",
"diablomedia/zendframework1-loader": "^1.0.1",
"diablomedia/zendframework1-locale": "^1.0.0",
"diablomedia/zendframework1-log": "^1.0.0",
"diablomedia/zendframework1-log-writer-db": "^1.0.0",
"diablomedia/zendframework1-log-writer-firebug": "^1.0.0",
"diablomedia/zendframework1-log-writer-mail": "^1.0.0",
"diablomedia/zendframework1-mail": "^1.0.0",
"diablomedia/zendframework1-mail": "^1.0.1",
"diablomedia/zendframework1-mime": "^1.0.0",
"diablomedia/zendframework1-navigation": "^1.0.0",
"diablomedia/zendframework1-oauth": "^1.0.0",
Expand All @@ -61,20 +61,20 @@
"diablomedia/zendframework1-service": "^1.0.0",
"diablomedia/zendframework1-service-amazon": "^1.0.0",
"diablomedia/zendframework1-service-recaptcha": "^1.0.0",
"diablomedia/zendframework1-session": "^1.0.0",
"diablomedia/zendframework1-session": "^1.0.2",
"diablomedia/zendframework1-session-savehandler-dbtable": "^1.0.0",
"diablomedia/zendframework1-soap": "^1.0.0",
"diablomedia/zendframework1-stdlib": "^1.0.0",
"diablomedia/zendframework1-test": "^1.0.0",
"diablomedia/zendframework1-test": "^1.0.2|^2.0.1",
"diablomedia/zendframework1-text": "^1.0.0",
"diablomedia/zendframework1-translate": "^1.0.0",
"diablomedia/zendframework1-uri": "^1.0.0",
"diablomedia/zendframework1-validate": "^1.0.0",
"diablomedia/zendframework1-validate-db": "^1.0.0",
"diablomedia/zendframework1-validate-file": "^1.0.0",
"diablomedia/zendframework1-validate-file": "^1.0.2",
"diablomedia/zendframework1-validate-ldap": "^1.0.0",
"diablomedia/zendframework1-validate-sitemap": "^1.0.0",
"diablomedia/zendframework1-view": "^1.0.0",
"diablomedia/zendframework1-view": "^1.0.2",
"diablomedia/zendframework1-view-helper-action": "^1.0.0",
"diablomedia/zendframework1-view-helper-baseurl": "^1.0.0",
"diablomedia/zendframework1-view-helper-json": "^1.0.0",
Expand Down Expand Up @@ -161,9 +161,9 @@
}
],
"require-dev": {
"phpunit/phpunit": "^6.0",
"phpunit/dbunit": "^3.0.2",
"phpunit/phpcov": "^4.0",
"phpunit/phpunit": "^7.0",
"phpunit/dbunit": "^4.0",
"phpunit/phpcov": "^5.0",
"phpstan/phpstan": "^0.9.2",
"jetbrains/phpstorm-stubs": "dev-phpstan"
},
Expand Down
5 changes: 4 additions & 1 deletion library/Zend/Feed/Entry/Atom.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ public function delete()
// Redirect
case 3:
$deleteUri = $response->getHeader('Location');
continue;
// This continue throws a warning in PHP 7.3+ so changed to a break to maintain existing
// behavior (which may not be the originally desired behavior)
//continue;
break;
// Error
default:
throw new Zend_Feed_Exception("Expected response code 2xx, got $httpStatus");
Expand Down
15 changes: 12 additions & 3 deletions library/Zend/Pdf/FileParser/Font/OpenType.php
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,10 @@ protected function _parseCmapTable()
if ($language != 0) {
$this->_debugLog('Type 0 cmap tables must be language-independent;'
. ' language: %d; skipping', $language);
continue;
// This continue throws a warning in PHP 7.3+ so changed to a break to maintain existing
// behavior (which may not be the originally desired behavior)
//continue;
break;
}
break;

Expand All @@ -949,7 +952,10 @@ protected function _parseCmapTable()
case 0xa: // break intentionally omitted
case 0xc:
$this->_debugLog('Format: 0x%x currently unsupported; skipping', $format);
continue;
// This continue throws a warning in PHP 7.3+ so changed to a break to maintain existing
// behavior (which may not be the originally desired behavior)
//continue;
break;
//$this->skipBytes(2);
//$cmapLength = $this->readUInt(4);
//$language = $this->readUInt(4);
Expand All @@ -961,7 +967,10 @@ protected function _parseCmapTable()

default:
$this->_debugLog('Unknown subtable format: 0x%x; skipping', $format);
continue;
// This continue throws a warning in PHP 7.3+ so changed to a break to maintain existing
// behavior (which may not be the originally desired behavior)
//continue;
break;
}
$cmapType = $format;
break;
Expand Down
15 changes: 12 additions & 3 deletions library/Zend/Reflection/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ protected function _reflect()
case T_DOLLAR_OPEN_CURLY_BRACES:
case T_CURLY_OPEN:
$embeddedVariableTrapped = true;
continue;
// This continue throws a warning in PHP 7.3+ so changed to a break to maintain existing
// behavior (which may not be the originally desired behavior)
//continue;
break;

// Name of something
case T_STRING:
Expand All @@ -348,15 +351,21 @@ protected function _reflect()
$this->_classes[] = $value;
$classTrapped = false;
}
continue;
// This continue throws a warning in PHP 7.3+ so changed to a break to maintain existing
// behavior (which may not be the originally desired behavior)
//continue;
break;

// Required file names are T_CONSTANT_ENCAPSED_STRING
case T_CONSTANT_ENCAPSED_STRING:
if ($requireTrapped) {
$this->_requiredFiles[] = $value ."\n";
$requireTrapped = false;
}
continue;
// This continue throws a warning in PHP 7.3+ so changed to a break to maintain existing
// behavior (which may not be the originally desired behavior)
//continue;
break;

// Functions
case T_FUNCTION:
Expand Down
4 changes: 3 additions & 1 deletion library/Zend/Serializer/Adapter/PhpCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class Zend_Serializer_Adapter_PhpCode extends Zend_Serializer_Adapter_AdapterAbs
*/
public function serialize($value, array $opts = array())
{
return var_export($value, true);
// preg_replace here is to fix stdClass serializing which can't be eval'd
// This behavior is fixed in PHP 7.3 (https://github.com/php/php-src/pull/2420)
return preg_replace("/stdClass::__set_state\((.*)\)/s", "(object) $1", var_export($value, true));
}
/**
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ parameters:
- '#Call to an undefined method Zend_Tool_Project_Profile_Resource_Container::.+\(\)\.#'
- '#Call to an undefined method Zend_Uri::.+\(\)\.#'
- '#Call to an undefined method Zend_XmlRpc_Client_ServerProxy::.+\(\)\.#'
- '#Call to an undefined method DOMNode::getAttribute\(\)\.#'
- '#Cannot access property \$commands on array\.#'
- '#Cannot access property \$description on array\.#'
- '#Cannot access property \$footers on array\.#'
Expand Down
6 changes: 2 additions & 4 deletions tests/Zend/Serializer/Adapter/PhpCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function testSerializeNumeric()
public function testSerializeObject()
{
$value = new stdClass();
$expected = "stdClass::__set_state(array(\n))";
$expected = "(object) array(\n)";

$data = $this->_adapter->serialize($value);
$this->assertEquals($expected, $data);
Expand Down Expand Up @@ -128,16 +128,14 @@ public function testUnserializeNumeric()
$this->assertEquals($expected, $data);
}

/* TODO: PHP Fatal error: Call to undefined method stdClass::__set_state()
public function testUnserializeObject()
{
$value = "stdClass::__set_state(array(\n))";
$value = "(object) array(\n)";
$expected = new stdClass();

$data = $this->_adapter->unserialize($value);
$this->assertEquals($expected, $data);
}
*/

public function testUnserialzeInvalid()
{
Expand Down

0 comments on commit eab45fd

Please sign in to comment.