Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHPUnit errors #210

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 41 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,57 @@ sudo: false

matrix:
include:
- php: 7.2
- php: 7.1
- php: 7.0
- php: 5.6
- php: 5.5
- php: 5.4
- php: hhvm
keesiemeijer marked this conversation as resolved.
Show resolved Hide resolved

before_install:
# Setup WP_TESTS_DIR (needed to bootstrap WP PHPUnit tests).
- export WP_TESTS_DIR=/tmp/wordpress/tests/phpunit/
# Clone the WordPress develop repo.
- git clone --depth=1 --branch="4.3" git://develop.git.wordpress.org/ /tmp/wordpress/
# Setup DB.
- mysql -e "CREATE DATABASE wordpress_test;" -uroot
# Setup wp-config.
- cp /tmp/wordpress/wp-tests-config-sample.php /tmp/wordpress/wp-tests-config.php
- sed -i "s/youremptytestdbnamehere/wordpress_test/" /tmp/wordpress/wp-tests-config.php
- sed -i "s/yourusernamehere/root/" /tmp/wordpress/wp-tests-config.php
- sed -i "s/yourpasswordhere//" /tmp/wordpress/wp-tests-config.php
# Setup WP_TESTS_DIR (needed to bootstrap WP PHPUnit tests).
- export WP_TESTS_DIR=/tmp/wordpress/tests/phpunit/
# http serves a single offer, whereas https serves multiple. we only want one
- curl -s http://api.wordpress.org/core/version-check/1.7/ > /tmp/wp-latest.json
- WP_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
- printf "Cloning WordPress %s\n" "$WP_VERSION"
# Clone the WordPress develop repo.
- git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ /tmp/wordpress/
# Setup DB.
- mysql -e "CREATE DATABASE wordpress_test;" -uroot
# Setup wp-config.
- cp /tmp/wordpress/wp-tests-config-sample.php /tmp/wordpress/wp-tests-config.php
- sed -i "s/youremptytestdbnamehere/wordpress_test/" /tmp/wordpress/wp-tests-config.php
- sed -i "s/yourusernamehere/root/" /tmp/wordpress/wp-tests-config.php
- sed -i "s/yourpasswordhere//" /tmp/wordpress/wp-tests-config.php

install: composer install --no-dev

before_script:
- |
# Export Composer's global bin dir to PATH, but not on PHP 5.2:
if [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then
composer config --list --global
export PATH=`composer config --list --global | grep '\[home\]' | { read a; echo "${a#* }/vendor/bin:$PATH"; }`
fi
- |
# Install the specified version of PHPUnit depending on the PHP version:
case "$TRAVIS_PHP_VERSION" in
7.3|7.2|7.1|7.0|nightly)
echo "Using PHPUnit 6.x"
travis_retry composer global require "phpunit/phpunit:^6"
# See trac ticket #43218 for when we can use PHPUnit 7
;;
5.6|5.5|5.4|5.3)
echo "Using PHPUnit 4.x"
travis_retry composer global require "phpunit/phpunit:^4"
;;
*)
echo "No PHPUnit version handling for PHP version $TRAVIS_PHP_VERSION"
exit 1
;;
esac

script:
- phpunit

Expand Down
5 changes: 4 additions & 1 deletion lib/class-file-reflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ public function leaveNode( \PHPParser_Node $node ) {
break;

case 'Stmt_Function':
end( $this->functions )->uses = array_pop( $this->location )->uses;
$function = array_pop( $this->location );
if ( isset( $function->uses ) && ! empty( $function->uses ) ) {
end( $this->functions )->uses = $function->uses;
}
break;

case 'Stmt_ClassMethod':
Expand Down