-
Couldn't load subscription status.
- Fork 0
Tests #1
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
Merged
Merged
Tests #1
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3b6bfb6
Add unit tests
Rahe a92849e
Remove pecl, use new values for the extensions
Rahe 5e6e16b
Use right extensions name for the config file
Rahe dd313e8
Add missing mysql service
Rahe 06f7aa6
Start mysql service
Rahe 87bd642
Rename psalm action, use global phpunit
Rahe 4b9c85b
Use the rool to install phpunit
Rahe ba6e44b
Remove mysqladmin error, change the phpunit version to fixed one
Rahe 1e7241d
Remove -e argument not known
Rahe 8a7a568
Remove prestissimo
Rahe 9a1ed95
change for php-parael-lint right function
Rahe 285aaac
Move quality to another pipeline, add tests for only certain versions
Rahe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ tests | |
| .env.testing | ||
| .gitignore | ||
| .DS_Store | ||
| .github | ||
| composer.json | ||
| composer.lock | ||
| grumphp.yml | ||
|
|
||
46 changes: 46 additions & 0 deletions
.github/workflows/ci.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: CI | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| run: | ||
| runs-on: ${{ matrix.operating-system }} | ||
| services: | ||
| mysql: | ||
| image: mysql:5.7 | ||
| env: | ||
| MYSQL_ALLOW_EMPTY_PASSWORD: false | ||
| MYSQL_ROOT_PASSWORD: root | ||
| MYSQL_DATABASE: wordpress_test | ||
| ports: | ||
| - 3306/tcp | ||
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
| strategy: | ||
| matrix: | ||
| operating-system: [ ubuntu-latest ] | ||
| php-versions: [ '7.1', '7.2', '7.3' ] | ||
| name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v1 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php-versions }} | ||
| extensions: mbstring, intl #optional, setup extensions | ||
| ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration | ||
| coverage: xdebug #optional, setup coverage driver | ||
| tools: psalm, phpcbf, phpcs, phpunit:5.7.27 | ||
|
|
||
| - name: Start mysql service | ||
| run: sudo /etc/init.d/mysql start | ||
|
|
||
| - name: Check PHP Version | ||
| run: php -v | ||
|
|
||
| - name: Install WP Tests | ||
| run: bash bin/install-wp-tests.sh wordpress_test root root localhost latest | ||
|
|
||
| - name: phpunit tests | ||
| run: phpunit |
38 changes: 38 additions & 0 deletions
.github/workflows/quality.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: Quality | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| run: | ||
| runs-on: ${{ matrix.operating-system }} | ||
| strategy: | ||
| matrix: | ||
| operating-system: [ ubuntu-latest ] | ||
| php-versions: [ 7.4' ] | ||
| name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v1 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php-versions }} | ||
| extensions: mbstring, intl #optional, setup extensions | ||
| ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration | ||
| coverage: xdebug #optional, setup coverage driver | ||
| tools: psalm, phpcbf, phpcs | ||
| - name: Check PHP Version | ||
| run: php -v | ||
|
|
||
| - name: Add dependencies | ||
| run: composer install | ||
|
|
||
| - name: Check composer | ||
| run: composer validate | ||
|
|
||
| - name: Check cs | ||
| run: composer cs | ||
|
|
||
| - name: Check psalm | ||
| run: composer psalm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,6 @@ | |
|
|
||
| # Release | ||
| /bin/release/ | ||
|
|
||
| # Tests | ||
| /tests/*.txt | ||
155 changes: 155 additions & 0 deletions
bin/install-wp-tests.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| if [ $# -lt 3 ]; then | ||
| echo "usage: 0ドル <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]" | ||
| exit 1 | ||
| fi | ||
|
|
||
| DB_NAME=1ドル | ||
| DB_USER=2ドル | ||
| DB_PASS=3ドル | ||
| DB_HOST=${4-localhost} | ||
| WP_VERSION=${5-latest} | ||
| SKIP_DB_CREATE=${6-false} | ||
|
|
||
| TMPDIR=${TMPDIR-/tmp} | ||
| TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") | ||
| WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib} | ||
| WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/} | ||
|
|
||
| download() { | ||
| if [ `which curl` ]; then | ||
| curl -s "1ドル" > "2ドル"; | ||
| elif [ `which wget` ]; then | ||
| wget -nv -O "2ドル" "1ドル" | ||
| fi | ||
| } | ||
|
|
||
| if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then | ||
| WP_BRANCH=${WP_VERSION%\-*} | ||
| WP_TESTS_TAG="branches/$WP_BRANCH" | ||
|
|
||
| elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then | ||
| WP_TESTS_TAG="branches/$WP_VERSION" | ||
| elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
| if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then | ||
| # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x | ||
| WP_TESTS_TAG="tags/${WP_VERSION%??}" | ||
| else | ||
| WP_TESTS_TAG="tags/$WP_VERSION" | ||
| fi | ||
| elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then | ||
| WP_TESTS_TAG="trunk" | ||
| else | ||
| # http serves a single offer, whereas https serves multiple. we only want one | ||
| download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json | ||
| grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json | ||
| LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') | ||
| if [[ -z "$LATEST_VERSION" ]]; then | ||
| echo "Latest WordPress version could not be found" | ||
| exit 1 | ||
| fi | ||
| WP_TESTS_TAG="tags/$LATEST_VERSION" | ||
| fi | ||
| set -ex | ||
|
|
||
| install_wp() { | ||
|
|
||
| if [ -d $WP_CORE_DIR ]; then | ||
| return; | ||
| fi | ||
|
|
||
| mkdir -p $WP_CORE_DIR | ||
|
|
||
| if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then | ||
| mkdir -p $TMPDIR/wordpress-nightly | ||
| download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip | ||
| unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/ | ||
| mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR | ||
| else | ||
| if [ $WP_VERSION == 'latest' ]; then | ||
| local ARCHIVE_NAME='latest' | ||
| elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then | ||
| # https serves multiple offers, whereas http serves single. | ||
| download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json | ||
| if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then | ||
| # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x | ||
| LATEST_VERSION=${WP_VERSION%??} | ||
| else | ||
| # otherwise, scan the releases and get the most up to date minor version of the major release | ||
| local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` | ||
| LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1) | ||
| fi | ||
| if [[ -z "$LATEST_VERSION" ]]; then | ||
| local ARCHIVE_NAME="wordpress-$WP_VERSION" | ||
| else | ||
| local ARCHIVE_NAME="wordpress-$LATEST_VERSION" | ||
| fi | ||
| else | ||
| local ARCHIVE_NAME="wordpress-$WP_VERSION" | ||
| fi | ||
| download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz | ||
| tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR | ||
| fi | ||
|
|
||
| download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php | ||
| } | ||
|
|
||
| install_test_suite() { | ||
| # portable in-place argument for both GNU sed and Mac OSX sed | ||
| if [[ $(uname -s) == 'Darwin' ]]; then | ||
| local ioption='-i.bak' | ||
| else | ||
| local ioption='-i' | ||
| fi | ||
|
|
||
| # set up testing suite if it doesn't yet exist | ||
| if [ ! -d $WP_TESTS_DIR ]; then | ||
| # set up testing suite | ||
| mkdir -p $WP_TESTS_DIR | ||
| svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes | ||
| svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data | ||
| fi | ||
|
|
||
| if [ ! -f wp-tests-config.php ]; then | ||
| download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php | ||
| # remove all forward slashes in the end | ||
| WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") | ||
| sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php | ||
| sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
| sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
| sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
| sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php | ||
| fi | ||
|
|
||
| } | ||
|
|
||
| install_db() { | ||
|
|
||
| if [ ${SKIP_DB_CREATE} = "true" ]; then | ||
| return 0 | ||
| fi | ||
|
|
||
| # parse DB_HOST for port or socket references | ||
| local PARTS=(${DB_HOST//\:/ }) | ||
| local DB_HOSTNAME=${PARTS[0]}; | ||
| local DB_SOCK_OR_PORT=${PARTS[1]}; | ||
| local EXTRA="" | ||
|
|
||
| if ! [ -z $DB_HOSTNAME ] ; then | ||
| if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then | ||
| EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" | ||
| elif ! [ -z $DB_SOCK_OR_PORT ] ; then | ||
| EXTRA=" --socket=$DB_SOCK_OR_PORT" | ||
| elif ! [ -z $DB_HOSTNAME ] ; then | ||
| EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" | ||
| fi | ||
| fi | ||
|
|
||
| # create database | ||
| mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA | ||
| } | ||
|
|
||
| install_wp | ||
| install_test_suite | ||
| install_db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 54 additions & 50 deletions
composer.lock
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.