Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Added PHP tests #462

Merged
merged 34 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
af8a7bc
Initial setup for unit tests.
peterfabian Sep 20, 2018
ed46f3f
Added revenue stats tests.
peterfabian Sep 20, 2018
927798c
Fixed interval boundary function arguments in case no intervals are b…
peterfabian Sep 20, 2018
9fc63c3
Corrected hour representation in tests.
peterfabian Sep 21, 2018
5ea5853
Merge branch 'master' into fix/440
peterfabian Sep 21, 2018
6881459
The installation code should not run on each plugin load, only when a…
peterfabian Sep 21, 2018
8fd2bf3
Included product lookup in reports regeneration tool.
peterfabian Sep 21, 2018
3230f23
Travis test 1.
peterfabian Sep 21, 2018
8d2eb61
Travis test 2.
peterfabian Sep 21, 2018
57a72a5
Travis test 3.
peterfabian Sep 21, 2018
50e0eaa
Added /vendor/ to gitignore.
peterfabian Sep 21, 2018
6874a8c
Added Gutenberg installation to Travis.
peterfabian Sep 21, 2018
bb346b1
Travis test 4.
peterfabian Sep 21, 2018
b599c61
Travis test 5.
peterfabian Sep 21, 2018
c7c8b82
Travis test 6.
peterfabian Sep 21, 2018
a87f1f6
Travis test 7.
peterfabian Sep 21, 2018
f4b23db
Travis test 8.
peterfabian Sep 21, 2018
c2bdc8e
Travis test 9.
peterfabian Sep 21, 2018
09b5469
Travis test 10.
peterfabian Sep 21, 2018
f54ad27
Travis test 11.
peterfabian Sep 21, 2018
6c8c97c
Travis test 12.
peterfabian Sep 21, 2018
551f800
Travis test 13.
peterfabian Sep 21, 2018
7bd9107
Removed duplicate WooCommerce installation.
peterfabian Sep 21, 2018
0dde803
PHPCS updates.
peterfabian Sep 21, 2018
70a9397
Updated db prefix.
peterfabian Sep 21, 2018
23b37d6
Update dependencies installation for testing, corrected db prefix.
peterfabian Sep 24, 2018
15002e6
PHPCS fixes.
peterfabian Sep 24, 2018
6dba1f8
Updated language domain.
peterfabian Sep 24, 2018
2fb5f3e
Plugin installation should not be needed in bootstrap, as it happens …
peterfabian Sep 24, 2018
83d064e
Updated language domain.
peterfabian Sep 24, 2018
10b357d
Use node version 8.
peterfabian Sep 24, 2018
7936f91
Updated the before_script instructions to correctly install node and …
peterfabian Sep 24, 2018
9790a5f
Added missing data update triggers.
peterfabian Sep 24, 2018
b19e72d
Added remaining test files.
peterfabian Sep 24, 2018
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ languages/*
!languages/README.md

.idea

# Composer
/vendor/
29 changes: 27 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
sudo: false
language: node_js
sudo: required

language: php
php:
- 7.1

env:
- WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1 WP_CORE_DIR=/tmp/wordpress NODE_RELEASE=8.x

before_script:
- phpenv config-rm xdebug.ini
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- bash bin/install-wp-tests.sh wc_admin_test root '' localhost $WP_VERSION
- bash bin/travis.sh before
- sudo rm -rf ~/.nvm
- curl -sL "https://deb.nodesource.com/setup_${NODE_RELEASE}" | sudo -E bash -
- sudo apt-get install -y nodejs
- node --version
- npm --version


install:
- npm install

node_js:
- "8"

script:
- npm run lint
- npm test
- bash bin/phpunit.sh
- bash bin/phpcs.sh
40 changes: 40 additions & 0 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,46 @@ install_db() {
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
}

install_deps() {

# Script Variables
WP_SITE_URL="http://local.wordpress.test"
BRANCH=$TRAVIS_BRANCH
REPO=$TRAVIS_REPO_SLUG
WORKING_DIR="$PWD"

if [ "$TRAVIS_PULL_REQUEST_BRANCH" != "" ]; then
BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
REPO=$TRAVIS_PULL_REQUEST_SLUG
fi

# Set up WordPress using wp-cli
mkdir -p "$WP_CORE_DIR"
cd "$WP_CORE_DIR"

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar core config --dbname=$DB_NAME --dbuser=$DB_USER --dbpass=$DB_PASS --dbhost=$DB_HOST --dbprefix=wptests_
php wp-cli.phar core install --url="$WP_SITE_URL" --title="Example" --admin_user=admin --admin_password=password --admin_email=info@example.com --path=$WP_CORE_DIR --skip-email

# Install Gutenberg
php wp-cli.phar plugin install gutenberg --activate

# Install WooCommerce
cd "wp-content/plugins/"
# As zip file does not include tests, we have to get it from git repo.
git clone https://github.com/woocommerce/woocommerce.git
cd "$WP_CORE_DIR"
php wp-cli.phar plugin activate woocommerce

# Install wc-admin, the correct branch
php wp-cli.phar plugin install https://github.com/$REPO/archive/$BRANCH.zip --activate

# Back to original dir
cd "$WORKING_DIR"

}

install_wp
install_test_suite
install_db
install_deps
10 changes: 10 additions & 0 deletions bin/phpcs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

if [[ ${RUN_PHPCS} == 1 ]]; then
CHANGED_FILES=`git diff --name-only --diff-filter=ACMR $TRAVIS_COMMIT_RANGE | grep \\\\.php | awk '{print}' ORS=' '`

if [ "$CHANGED_FILES" != "" ]; then
echo "Running Code Sniffer."
./vendor/bin/phpcs --encoding=utf-8 -n -p $CHANGED_FILES
fi
fi
5 changes: 5 additions & 0 deletions bin/phpunit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
WORKING_DIR="$PWD"
cd "/tmp/wordpress/wp-content/plugins/wc-admin/"
phpunit -c phpunit.xml.dist
cd "$WORKING_DIR"
12 changes: 12 additions & 0 deletions bin/travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# usage: travis.sh before|after

if [ $1 == 'before' ]; then

composer global require "phpunit/phpunit=6.*"

if [[ ${RUN_PHPCS} == 1 ]]; then
composer install
fi

fi
38 changes: 38 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "woocommerce/wc-admin",
"description": "A modern, javascript-driven WooCommerce Admin experience.",
"homepage": "https://github.com/woocommerce/wc-admin",
"type": "wordpress-plugin",
"license": "GPL-3.0-or-later",
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"composer/installers": "~1.2"
},
"require-dev": {
"squizlabs/php_codesniffer": "*",
"wp-coding-standards/wpcs": "^0.14",
"phpunit/phpunit": "6.*",
"woocommerce/woocommerce-sniffs": "*",
"wimg/php-compatibility": "^8.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
},
"scripts": {
"test": [
"phpunit"
],
"phpcs": [
"phpcs -s -p"
],
"phpcbf": [
"phpcbf -p"
]
},
"extra": {
"scripts-description": {
"test": "Run unit tests",
"phpcs": "Analyze code against the WordPress coding standards with PHP_CodeSniffer",
"phpcbf": "Fix coding standards warnings/errors automatically with PHP Code Beautifier"
}
}
}
Loading