From ab4b00db149dfb5f0abd6d29a5e248ba6e0fc556 Mon Sep 17 00:00:00 2001 From: Whizark Date: Tue, 15 Dec 2015 00:14:12 +0900 Subject: [PATCH] chore: prepare test environment --- .coveralls.yml | 3 +++ .gitattributes | 3 +++ .travis.yml | 48 +++++++++++++++++++++++++++++++++ composer.json | 8 +++++- phpunit.xml.dist | 27 +++++++++++++++++++ tests/Devaloka/DevalokaTest.php | 31 +++++++++++++++++++++ tests/bootstrap.php | 10 +++++++ 7 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 .coveralls.yml create mode 100644 phpunit.xml.dist create mode 100644 tests/Devaloka/DevalokaTest.php create mode 100644 tests/bootstrap.php diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..e30743e --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,3 @@ +service_name: travis-ci +src_dir: src +coverage_clover: build/logs/clover.xml diff --git a/.gitattributes b/.gitattributes index c0424c3..483889d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,4 +8,7 @@ package.json export-ignore npm-shrinkwrap.json export-ignore .mdastrc export-ignore composer.json export-ignore +phpunit.xml.dist export-ignore +.coveralls.yml export-ignore +tests/ export-ignore .travis.yml export-ignore diff --git a/.travis.yml b/.travis.yml index 69156fa..38869f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,19 +8,67 @@ php: - '7.0' - hhvm +env: + - WP_VERSION=4.3 WP_MULTISITE=0 + - WP_VERSION=4.3 WP_MULTISITE=1 + - WP_VERSION=4.4 WP_MULTISITE=0 + - WP_VERSION=4.4 WP_MULTISITE=1 + +matrix: + fast_finish: true + allow_failures: + - php: hhvm + cache: directories: - node_modules + - $HOME/.composer/cache/files before_install: - npm config set spin false - npm install -g npm + - composer self-update install: - npm install + - composer install --prefer-source + +before_script: + - BUILD_PATH="$(pwd)" + - BUILD_DIR="$(basename "$BUILD_PATH")" + - BASE_PATH=/tmp + - WP_CORE_DIR=wordpress + - WP_CORE_PATH="$BASE_PATH/$WP_CORE_DIR" + - WP_TESTS_LIB_DIR=wordpress-tests-lib + - WP_TESTS_LIB_PATH="$BASE_PATH/$WP_TESTS_LIB_DIR" + - DB_NAME=wordpress_tests + - COMPONENT_DIR=mu-plugins + - LOADER_FILE=loader/00-devaloka-loader.php + - wget -nv -O "$BASE_PATH/wordpress-$WP_VERSION.tar.gz" "https://wordpress.org/wordpress-$WP_VERSION.tar.gz" + - mkdir -p "$WP_CORE_PATH" + - tar --strip-components=1 -zxmf "$BASE_PATH/wordpress-$WP_VERSION.tar.gz" -C "$WP_CORE_PATH" + - wget -nv -O "$WP_CORE_PATH/wp-content/db.php" https://raw.github.com/markoheijnen/wp-mysqli/master/db.php + - mkdir -p $WP_TESTS_LIB_PATH + - svn export --quiet "https://develop.svn.wordpress.org/tags/$WP_VERSION/tests/phpunit/includes/" "$WP_TESTS_LIB_PATH/includes" + - wget -nv -O "$WP_TESTS_LIB_PATH/wp-tests-config.php" "https://develop.svn.wordpress.org/tags/$WP_VERSION/wp-tests-config-sample.php" + - sed -i "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_PATH/':" "$WP_TESTS_LIB_PATH/wp-tests-config.php" + - sed -i "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_LIB_PATH/wp-tests-config.php" + - sed -i "s/yourusernamehere/travis/" "$WP_TESTS_LIB_PATH/wp-tests-config.php" + - sed -i "s/yourpasswordhere//" "$WP_TESTS_LIB_PATH/wp-tests-config.php" + - mysqladmin create "$DB_NAME" --user="root" + - mv vendor $WP_CORE_PATH/ + - if [[ -e wp-content ]]; then mv -f wp-content $WP_CORE_PATH/; fi + - mkdir -p "$WP_CORE_PATH/wp-content/$COMPONENT_DIR/$BUILD_DIR" + - cp -rf "$BUILD_PATH" "$WP_CORE_PATH/wp-content/$COMPONENT_DIR/" + - cp -rf "$BUILD_PATH/$LOADER_FILE" "$WP_CORE_PATH/wp-content/$COMPONENT_DIR/" + - cd "$WP_CORE_PATH/wp-content/$COMPONENT_DIR/$BUILD_DIR" script: - npm run-script lint-travis + - phpunit --colors --verbose --coverage-clover build/logs/clover.xml + +after_script: + - "$WP_CORE_PATH/vendor/bin/coveralls --verbose --root_dir ." notifications: email: diff --git a/composer.json b/composer.json index af7deb8..cb2b1b5 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,11 @@ "pimple/pimple" : "~3.0", "symfony/event-dispatcher" : "~3.0" }, + "require-dev" : { + "phpunit/phpunit" : "^4.8 || ^5.1", + "mockery/mockery" : "^0.9.4", + "satooshi/php-coveralls": "~0.7.0" + }, "archive" : { "exclude": [ ".gitignore", @@ -48,7 +53,8 @@ "npm-shrinkwrap.json", ".mdastrc", "composer.json", - ".travis.yml" + ".travis.yml", + "tests" ] }, "extra" : { diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..04a5e2c --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,27 @@ + + + + + + ./tests/ + + + + + + ./src/ + ./devaloka.php + + + diff --git a/tests/Devaloka/DevalokaTest.php b/tests/Devaloka/DevalokaTest.php new file mode 100644 index 0000000..b5e4854 --- /dev/null +++ b/tests/Devaloka/DevalokaTest.php @@ -0,0 +1,31 @@ +add('Tests\\Devaloka\\', __DIR__ . '/Devaloka/');