diff --git a/.drone.jsonnet b/.drone.jsonnet index 7b688c3b..45cd9996 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -28,16 +28,13 @@ local Pipeline(php_version, wp_version = "latest") = commands: [ // install build deps "make build.tools", - // install wordpress - "make wordpress.build WP_VERSION=%s" % wp_version, ], }, { name: "test", image: "docker.io/presslabs/php-runtime:%s" % php_version, commands: [ - "make test", - //"WP_MULTISITE=1 phpunit", + "make test WP_VERSION=%s" % wp_version, ], }, { diff --git a/.drone.yml b/.drone.yml index efd1173c..a4dbc0c7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,14 +21,13 @@ steps: tags: true - commands: - make build.tools - - make wordpress.build WP_VERSION=latest environment: WP_CORE_DIR: /workspace/presslabs/toplytics/wordpress WP_TEST_DIR: /workspace/presslabs/toplytics/wordpress-test-lib image: quay.io/presslabs/build:latest name: install deps - commands: - - make test + - make test WP_VERSION=latest image: docker.io/presslabs/php-runtime:8.0 name: test - commands: diff --git a/Makefile b/Makefile index 63b75480..fa707458 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,10 @@ PROJECT_NAME := toplytics PROJECT_REPO := github.com/presslabs/toplytics +WP_VERSION ?= 6.0.1 + include build/makelib/common.mk include build/makelib/wordpress.mk include build/makelib/php.mk -WP_CLI_VERSION:=2.6.0 -WP_CLI_DOWNLOAD_URL:=https://github.com/wp-cli/wp-cli/releases/download/v$(WP_CLI_VERSION)/wp-cli-$(WP_CLI_VERSION).phar -$(eval $(call tool.download,wp,$(WP_CLI_VERSION),$(WP_CLI_DOWNLOAD_URL))) - -# override php tests because of wordpress.mk -.php.test.init: - @$(INFO) test wordpress pass +.php.test.init: $(WP_TESTS_DIR)/src/wp-includes/version.php $(WP_TESTS_DIR)/includes $(WP_TESTS_DIR)/data diff --git a/build/makelib/wordpress.mk b/build/makelib/wordpress.mk index 2df20cb3..d9e62f3b 100644 --- a/build/makelib/wordpress.mk +++ b/build/makelib/wordpress.mk @@ -59,6 +59,13 @@ $(WP_TESTS_DIR)/src/wp-includes/version.php: $(WP_TESTS_ARCHIVE) $(WP_TESTS_DIR)/wp-tests-config.php: $(WP_TESTS_CONFIG) $(WP_TESTS_DIR)/src/wp-includes/version.php @cp $(WP_TESTS_CONFIG) $@ +$(WP_TESTS_DIR)/includes: $(WP_TESTS_DIR) + @cp -r $(WP_TESTS_DIR)/tests/phpunit/includes $@ + +$(WP_TESTS_DIR)/data: $(WP_TESTS_DIR) + @cp -r $(WP_TESTS_DIR)/tests/phpunit/data $@ + + # add WP_TESTS_DIR env var for running tests .do.php.test: PHPUNIT:=WP_TESTS_DIR=$(WP_TESTS_DIR) $(PHPUNIT) diff --git a/composer.json b/composer.json index 374bd487..6e154651 100755 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "google/apiclient": "^2.10" }, "require-dev": { - "phpunit/phpunit": "<8" + "phpunit/phpunit": "<8", + "yoast/phpunit-polyfills": "^1.0" }, "scripts": { "pre-autoload-dump": "Google\\Task\\Composer::cleanup" diff --git a/composer.lock b/composer.lock index 72f90b7a..1f7d523f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d378a9a7a6240d9a3bbf32957c601c79", + "content-hash": "a7c435b9fe9d0f451365118047f818bb", "packages": [ { "name": "firebase/php-jwt", @@ -2879,6 +2879,67 @@ "source": "https://github.com/webmozarts/assert/tree/1.11.0" }, "time": "2022-06-03T18:03:27+00:00" + }, + { + "name": "yoast/phpunit-polyfills", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", + "reference": "5ea3536428944955f969bc764bbe09738e151ada" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/5ea3536428944955f969bc764bbe09738e151ada", + "reference": "5ea3536428944955f969bc764bbe09738e151ada", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "require-dev": { + "yoast/yoastcs": "^2.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "files": [ + "phpunitpolyfills-autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Team Yoast", + "email": "support@yoast.com", + "homepage": "https://yoast.com" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Yoast/PHPUnit-Polyfills/graphs/contributors" + } + ], + "description": "Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests", + "homepage": "https://github.com/Yoast/PHPUnit-Polyfills", + "keywords": [ + "phpunit", + "polyfill", + "testing" + ], + "support": { + "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues", + "source": "https://github.com/Yoast/PHPUnit-Polyfills" + }, + "time": "2021-11-23T01:37:03+00:00" } ], "aliases": [], diff --git a/tests/wp-tests-config.php b/tests/wp-tests-config.php index 969e7247..4efbc00f 100644 --- a/tests/wp-tests-config.php +++ b/tests/wp-tests-config.php @@ -48,3 +48,24 @@ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! + * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} + */ +define( 'AUTH_KEY', 'put your unique phrase here' ); +define( 'SECURE_AUTH_KEY', 'put your unique phrase here' ); +define( 'LOGGED_IN_KEY', 'put your unique phrase here' ); +define( 'NONCE_KEY', 'put your unique phrase here' ); +define( 'AUTH_SALT', 'put your unique phrase here' ); +define( 'SECURE_AUTH_SALT', 'put your unique phrase here' ); +define( 'LOGGED_IN_SALT', 'put your unique phrase here' ); +define( 'NONCE_SALT', 'put your unique phrase here' ); + +$table_prefix = 'wptests_'; // Only numbers, letters, and underscores please! + +define( 'WP_TESTS_DOMAIN', 'example.org' ); +define( 'WP_TESTS_EMAIL', 'admin@example.org' ); +define( 'WP_TESTS_TITLE', 'Test Blog' ); + +define( 'WP_PHP_BINARY', 'php' ); + +define( 'WPLANG', '' ); +