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 php8.2 test error, xdebug default off on testing, allow php version switching #1511

Merged
merged 11 commits into from
Jul 24, 2024
Merged
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ package.lock
ui/js/*.min.js
ui/css/*.min.css
alerts/js/*.min.js

# Generated test data
tests/data/tmp/*
18 changes: 11 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"wp-cli/wp-cli-bundle": "^2.6",
"wp-coding-standards/wpcs": "^3.1",
"wp-phpunit/wp-phpunit": "^6.6",
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
"wpackagist-plugin/easy-digital-downloads": "2.9.23",
"wpackagist-plugin/jetpack": "10.0",
"wpackagist-plugin/user-switching": "1.5.5",
"wpackagist-plugin/wordpress-seo": "23.0",
"wpackagist-plugin/advanced-custom-fields": "6.3.4",
"wpackagist-plugin/easy-digital-downloads": "3.3.1",
"wpackagist-plugin/jetpack": "13.6",
"wpackagist-plugin/user-switching": "1.8.0",
"wpackagist-plugin/wordpress-seo": "23.1",
"wpackagist-theme/twentytwentythree": "^1.0",
"xwp/wait-for": "^0.0.1",
"yoast/phpunit-polyfills": "^1.1"
Expand Down Expand Up @@ -81,12 +81,16 @@
],
"test-one": [
"phpunit",
"WP_MULTISITE=1 phpunit"
"WP_MULTISITE=1 phpunit -c phpunit-multisite.xml"
],
"test-multisite": [
"WP_MULTISITE=1 phpunit --coverage-text",
"WP_MULTISITE=1 phpunit -c phpunit-multisite.xml --coverage-text",
"php local/scripts/make-clover-relative.php ./tests/reports/clover.xml"
],
"test-xdebug": [
"XDEBUG_TRIGGER=1 phpunit",
"WP_MULTISITE=1 XDEBUG_TRIGGER=1 phpunit -c phpunit-multisite.xml"
],
"test-report": [
"php-coveralls --verbose"
]
Expand Down
86 changes: 43 additions & 43 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions connectors/class-connector-edd.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ public function check_edd_settings( $old_value, $new_value ) {
* @return array|bool
*/
public function log_override( $data ) {

if ( ! is_array( $data ) ) {
return $data;
}
Expand Down Expand Up @@ -477,18 +478,19 @@ public function callback_edd_pre_update_discount_status( $code_id, $new_status )
sprintf(
/* translators: %1$s: a discount title, %2$s: a status (e.g. "Mother's Day", "activated") */
__( '"%1$s" discount %2$s', 'stream' ),
get_post( $code_id )->post_title,
edd_get_discount_field( $code_id, 'name' ),
'active' === $new_status ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' )
),
array(
'post_id' => $code_id,
'status' => $new_status,
'discount_id' => $code_id,
'status' => $new_status,
),
$code_id,
'discounts',
'updated'
);
}

/**
* Logs PDFs
*
Expand Down
4 changes: 4 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ We use npm as the canonical task runner for the project. The following commands
- `npm run deploy` to deploy the plugin to the WordPress.org repository.
- `npm run cli -- wp info` where `wp info` is the CLI command to run inside the WordPress container. For example, use `npm run cli -- ls -lah` to list all files in the root of the WordPress installation.
- `npm run test` to run PHPunit tests inside the WordPress container.
- `npm run test-xdebug` will run the PHPunit tests with Xdebug enabled.
- `npm run switch-to:php7.4` and `npm run switch-to:php8.2` will switch you to either PHP 7.4 or PHP 8.2

By default, tests have `WP_DEBUG` as false. You can override this if necessary by setting `WP_STREAM_TEST_DEBUG` to "yes".

### Docker issues

Expand Down
1 change: 0 additions & 1 deletion local/docker/wordpress/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sendmail_path = "/usr/bin/msmtp --port=1025 --read-recipients"
; Enable remote Xdebug.
[xdebug]
xdebug.mode = coverage,debug,develop
xdebug.start_with_request = yes
xdebug.client_host = host.docker.internal
xdebug.discover_client_host = 0
xdebug.remote_enable = 1
Expand Down
1 change: 0 additions & 1 deletion local/public/wp-content/plugins/hello.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
* Plugin Name: Hello Dolly
* Description: A plugin used for PHP unit tests
*/

2 changes: 1 addition & 1 deletion local/public/wp-tests-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Rely on Composer autoload to pull in tooling helpers.
require_once __DIR__ . '/wp-content/plugins/stream-src/vendor/autoload.php';

define( 'WP_DEBUG', true );
define( 'WP_DEBUG', isset( $_ENV['WP_STREAM_TEST_DEBUG'] ) ? $_ENV['WP_STREAM_TEST_DEBUG'] === 'yes' : false );

# Configured in docker-compose.yml.
define( 'DB_NAME', 'wordpress_test' );
Expand Down
Loading
Loading