From 0628827be4869960dfe5960823512005a825fa52 Mon Sep 17 00:00:00 2001 From: JJ Date: Wed, 17 Jul 2024 09:58:01 -0400 Subject: [PATCH 1/6] add test for WordPress SEO connector currently fails to reproduce https://github.com/xwp/stream/issues/1489, https://github.com/xwp/stream/issues/1443 --- .gitignore | 1 + composer.json | 5 ++ composer.lock | 20 ++++- local/public/wp-config.php | 1 + local/public/wp-content/plugins/hello.php | 1 + package.json | 1 + phpunit.xml | 2 +- tests/bootstrap.php | 1 + .../test-class-connector-wordpress-seo.php | 83 +++++++++++++++++++ 9 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 tests/tests/connectors/test-class-connector-wordpress-seo.php diff --git a/.gitignore b/.gitignore index 651787857..b472ff1b6 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /stream.zip /stream-*.zip npm-debug.log +debug.log package.lock .phpunit.result.cache diff --git a/composer.json b/composer.json index cd06d1236..91e3ba8f5 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "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-theme/twentytwentythree": "^1.0", "xwp/wait-for": "^0.0.1", "yoast/phpunit-polyfills": "^1.1" @@ -70,6 +71,10 @@ "phpunit --coverage-text", "php local/scripts/make-clover-relative.php ./tests/reports/clover.xml" ], + "test-one": [ + "phpunit", + "WP_MULTISITE=1 phpunit" + ], "test-multisite": [ "WP_MULTISITE=1 phpunit --coverage-text", "php local/scripts/make-clover-relative.php ./tests/reports/clover.xml" diff --git a/composer.lock b/composer.lock index a08bca72c..7ffeacaa2 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": "abf1540362c6e039be43d3cb8d21bc8d", + "content-hash": "ebfa2a164fed755007fb4579a422a26e", "packages": [ { "name": "composer/installers", @@ -8408,6 +8408,24 @@ "type": "wordpress-plugin", "homepage": "https://wordpress.org/plugins/user-switching/" }, + { + "name": "wpackagist-plugin/wordpress-seo", + "version": "23.0", + "source": { + "type": "svn", + "url": "https://plugins.svn.wordpress.org/wordpress-seo/", + "reference": "tags/23.0" + }, + "dist": { + "type": "zip", + "url": "https://downloads.wordpress.org/plugin/wordpress-seo.23.0.zip" + }, + "require": { + "composer/installers": "^1.0 || ^2.0" + }, + "type": "wordpress-plugin", + "homepage": "https://wordpress.org/plugins/wordpress-seo/" + }, { "name": "wpackagist-theme/twentytwentythree", "version": "1.4", diff --git a/local/public/wp-config.php b/local/public/wp-config.php index 42734f680..ae947c5ec 100644 --- a/local/public/wp-config.php +++ b/local/public/wp-config.php @@ -25,6 +25,7 @@ $table_prefix = 'wp_'; define( 'WP_DEBUG', true ); +define( 'WP_DEBUG_LOG', true ); define( 'JETPACK_DEV_DEBUG', true ); // Keep the wp-contents outside of WP core directory. diff --git a/local/public/wp-content/plugins/hello.php b/local/public/wp-content/plugins/hello.php index ae51ede30..cbbf79f15 100644 --- a/local/public/wp-content/plugins/hello.php +++ b/local/public/wp-content/plugins/hello.php @@ -4,3 +4,4 @@ * Description: A plugin used for PHP unit tests */ + diff --git a/package.json b/package.json index 8078e420e..114536e4d 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "test": "npm-run-all test:*", "test:php": "npm run cli -- composer test --working-dir=wp-content/plugins/stream-src", "test:php-multisite": "npm run cli -- composer test-multisite --working-dir=wp-content/plugins/stream-src", + "test:php:one": "npm run cli -- composer test-one --working-dir=wp-content/plugins/stream-src --", "test-report": "npm run cli -- composer test-report --working-dir=wp-content/plugins/stream-src", "build-containers": "docker compose --file docker-compose.build.yml build", "push-containers": "docker compose --file docker-compose.build.yml push", diff --git a/phpunit.xml b/phpunit.xml index f37a7bf54..1254c9721 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,7 +10,7 @@ diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 06b12bd93..8e445990b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -93,6 +93,7 @@ function( $status = false, $args = array(), $url = '') { define( 'EDD_USE_PHP_SESSIONS', false ); define( 'WP_USE_THEMES', false ); activate_plugin( 'easy-digital-downloads/easy-digital-downloads.php' ); +activate_plugin( 'wordpress-seo/wp-seo.php' ); xwp_install_edd(); require __DIR__ . '/testcase.php'; diff --git a/tests/tests/connectors/test-class-connector-wordpress-seo.php b/tests/tests/connectors/test-class-connector-wordpress-seo.php new file mode 100644 index 000000000..b9a5fa271 --- /dev/null +++ b/tests/tests/connectors/test-class-connector-wordpress-seo.php @@ -0,0 +1,83 @@ +plugin->connectors->unload_connectors(); + + // Make partial of Connector_WordPress_SEO class, with mocked "log" function. + $this->mock = $this->getMockBuilder( Connector_WordPress_SEO::class ) + ->setMethods( array( 'log' ) ) + ->getMock(); + + // Register connector. + $this->mock->register(); + } + + /** + * Confirm that WordPress SEO is installed and active. + */ + public function test_wordpress_seo_installed_and_activated() { + $this->assertTrue( defined( 'YOAST_ENVIRONMENT' ) ); + } + + /** + * Tests "added_post_meta" callback function. + * callback_added_post_meta( $meta_id, $object_id, $meta_key, $meta_value ) + */ + public function test_callback_added_post_meta() { + + // Set expected calls for the Mock. + $this->mock->expects( $this->once() ) + ->method( 'log' ) + ->with( + $this->equalTo( + __( 'Updated "SEO title" of "Test post %%!" Post', 'stream' ) + ), + $this->equalTo( + array( + 'meta_key' => $this->title_meta_key, + 'meta_value' => 'Test meta %!', + 'post_type' => 'post', + ) + ), + $this->greaterThan( 0 ), + 'wpseo_meta', + 'updated' + ); + + // Create post for later use. + $post_id = wp_insert_post( + array( + 'post_title' => 'Test post %!', + 'post_content' => 'Lorem ipsum dolor...', + 'post_status' => 'publish' + ) + ); + + update_post_meta( $post_id, $this->title_meta_key, 'Test meta %!' ); + + // Confirm callback execution. + $this->assertGreaterThan( 0, did_action( $this->action_prefix . 'callback_added_post_meta' ) ); + } +} From 75c32c457c3a5fa7cc8c635e9e07ebb570526db6 Mon Sep 17 00:00:00 2001 From: JJ Date: Wed, 17 Jul 2024 10:13:28 -0400 Subject: [PATCH 2/6] Add escape method for percentages, use in WordPress SEO connector Fixes https://github.com/xwp/stream/issues/1489, https://github.com/xwp/stream/pull/1485/files --- classes/class-connector.php | 10 ++++++++++ connectors/class-connector-wordpress-seo.php | 6 +++--- local/public/wp-content/plugins/hello.php | 1 - tests/tests/test-class-connector.php | 13 +++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/classes/class-connector.php b/classes/class-connector.php index 62142f0c4..9efbb519f 100644 --- a/classes/class-connector.php +++ b/classes/class-connector.php @@ -294,4 +294,14 @@ function( $value ) { public function is_dependency_satisfied() { return true; } + + /** + * Escape % characters in a string to avoid Uncaught ValueErrors in $this->log(). + * + * @param string $value The string value to be escaped. + * @return string The escaped string. + */ + public function escape_percentages( $value ) { + return str_replace( '%', '%%', $value ); + } } diff --git a/connectors/class-connector-wordpress-seo.php b/connectors/class-connector-wordpress-seo.php index 18614e965..8d6badc7c 100644 --- a/connectors/class-connector-wordpress-seo.php +++ b/connectors/class-connector-wordpress-seo.php @@ -419,9 +419,9 @@ private function meta( $object_id, $meta_key, $meta_value ) { sprintf( /* translators: %1$s: a meta field title, %2$s: a post title, %3$s: a post type (e.g. "Description", "Hello World", "Post") */ __( 'Updated "%1$s" of "%2$s" %3$s', 'stream' ), - $field['title'], - $post->post_title, - $post_type_label + $this->escape_percentages( $field['title'] ), + $this->escape_percentages( $post->post_title ), + $this->escape_percentages( $post_type_label ) ), array( 'meta_key' => $meta_key, diff --git a/local/public/wp-content/plugins/hello.php b/local/public/wp-content/plugins/hello.php index cbbf79f15..ae51ede30 100644 --- a/local/public/wp-content/plugins/hello.php +++ b/local/public/wp-content/plugins/hello.php @@ -4,4 +4,3 @@ * Description: A plugin used for PHP unit tests */ - diff --git a/tests/tests/test-class-connector.php b/tests/tests/test-class-connector.php index 8c189184f..b47c44121 100644 --- a/tests/tests/test-class-connector.php +++ b/tests/tests/test-class-connector.php @@ -177,6 +177,19 @@ public function test_get_changed_keys() { public function test_is_dependency_satisfied() { $this->assertTrue( $this->connector->is_dependency_satisfied() ); } + + /** + * Test that percentages are escaped. + * + * @return void + */ + public function test_escape_percentages() { + $escaped_value = $this->connector->escape_percentages( 'This is a message with a % sign' ); + $this->assertEquals( + 'This is a message with a %% sign', + $escaped_value + ); + } } class Connector_Maintenance extends Connector { From cca578ffa7e32ad57d691a0e6dbba971b7b4e286 Mon Sep 17 00:00:00 2001 From: JJ Date: Wed, 17 Jul 2024 12:45:31 -0400 Subject: [PATCH 3/6] Update Gravity Forms connector to escape percentages. Fixes https://github.com/xwp/stream/issues/1445. Also tweaks to unit tests, adds $mock to class and uses `onlyMethods()` in WPSEO tests mock. --- connectors/class-connector-gravityforms.php | 141 +++++++++++++----- tests/testcase.php | 7 + .../test-class-connector-wordpress-seo.php | 2 +- 3 files changed, 114 insertions(+), 36 deletions(-) diff --git a/connectors/class-connector-gravityforms.php b/connectors/class-connector-gravityforms.php index aa68ba5b7..ad84715c0 100644 --- a/connectors/class-connector-gravityforms.php +++ b/connectors/class-connector-gravityforms.php @@ -221,20 +221,23 @@ public function register() { * @param bool $is_new Is this a new form?. */ public function callback_gform_after_save_form( $form, $is_new ) { - $title = $form['title']; - $id = $form['id']; + $id = $form['id']; $this->log( sprintf( /* translators: %1$s a form title, %2$s a status (e.g. "Contact Form", "created") */ __( '"%1$s" form %2$s', 'stream' ), - $title, - $is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ) + $this->get_form_title_for_message( $form ), + $this->get_status_for_message( + $is_new, + esc_html__( 'created', 'stream' ), + esc_html__( 'updated', 'stream' ) + ) ), array( 'action' => $is_new, 'id' => $id, - 'title' => $title, + 'title' => $form['title'], ), $id, 'forms', @@ -258,9 +261,13 @@ public function callback_gform_pre_confirmation_save( $confirmation, $form, $is_ sprintf( /* translators: %1$s: a confirmation name, %2$s: a status, %3$s: a form title (e.g. "Email", "created", "Contact Form") */ __( '"%1$s" confirmation %2$s for "%3$s"', 'stream' ), - $confirmation['name'], - $is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ), - $form['title'] + $this->get_name_for_message( $confirmation ), + $this->get_status_for_message( + $is_new, + esc_html__( 'created', 'stream' ), + esc_html__( 'updated', 'stream' ) + ), + $this->get_form_title_for_message( $form ) ), array( 'is_new' => $is_new, @@ -291,9 +298,13 @@ public function callback_gform_pre_notification_save( $notification, $form, $is_ sprintf( /* translators: %1$s: a notification name, %2$s: a status, %3$s: a form title (e.g. "Email", "created", "Contact Form") */ __( '"%1$s" notification %2$s for "%3$s"', 'stream' ), - $notification['name'], - $is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ), - $form['title'] + $this->get_name_for_message( $notification ), + $this->get_status_for_message( + $is_new, + esc_html__( 'created', 'stream' ), + esc_html__( 'updated', 'stream' ) + ), + $this->get_form_title_for_message( $form ) ), array( 'is_update' => $is_new, @@ -318,8 +329,8 @@ public function callback_gform_pre_notification_deleted( $notification, $form ) sprintf( /* translators: %1$s: a notification name, %2$s: a form title (e.g. "Email", "Contact Form") */ __( '"%1$s" notification deleted from "%2$s"', 'stream' ), - $notification['name'], - $form['title'] + $this->get_name_for_message( $notification ), + $this->get_form_title_for_message( $form ) ), array( 'form_id' => $form['id'], @@ -342,8 +353,8 @@ public function callback_gform_pre_confirmation_deleted( $confirmation, $form ) sprintf( /* translators: %1$s: a confirmation name, %2$s: a form title (e.g. "Email", "Contact Form") */ __( '"%1$s" confirmation deleted from "%2$s"', 'stream' ), - $confirmation['name'], - $form['title'] + $this->get_name_for_message( $confirmation ), + $this->get_form_title_for_message( $form ) ), array( 'form_id' => $form['id'], @@ -367,9 +378,13 @@ public function callback_gform_confirmation_status( $confirmation, $form, $is_ac sprintf( /* translators: %1$s: a confirmation name, %2$s: a status, %3$s: a form title (e.g. "Email", "activated", "Contact Form") */ __( '"%1$s" confirmation %2$s from "%3$s"', 'stream' ), - $confirmation['name'], - $is_active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ), - $form['title'] + $this->get_name_for_message( $confirmation ), + $this->get_status_for_message( + $is_active, + esc_html__( 'activated', 'stream' ), + esc_html__( 'deactivated', 'stream' ) + ), + $this->get_form_title_for_message( $form ) ), array( 'form_id' => $form['id'], @@ -394,9 +409,13 @@ public function callback_gform_notification_status( $notification, $form, $is_ac sprintf( /* translators: %1$s: a notification name, %2$s: a status, %3$s: a form title (e.g. "Email", "activated", "Contact Form") */ __( '"%1$s" notification %2$s from "%3$s"', 'stream' ), - $notification['name'], - $is_active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ), - $form['title'] + $this->get_name_for_message( $notification ), + $this->get_status_for_message( + $is_active, + esc_html__( 'activated', 'stream' ), + esc_html__( 'deactivated', 'stream' ) + ), + $this->get_form_title_for_message( $form ) ), array( 'form_id' => $form['id'], @@ -514,7 +533,11 @@ public function check_rg_gforms_key( $old_value, $new_value ) { sprintf( /* translators: %s: a status (e.g. "updated") */ __( 'Gravity Forms license key %s', 'stream' ), - $is_update ? esc_html__( 'updated', 'stream' ) : esc_html__( 'deleted', 'stream' ) + $this->get_status_for_message( + $is_update, + esc_html__( 'updated', 'stream' ), + esc_html__( 'deleted', 'stream' ) + ) ), compact( 'option', 'old_value', 'new_value' ), null, @@ -755,8 +778,8 @@ public function callback_gform_update_status( $lead_id, $status, $prev = '' ) { /* translators: %1$d: an ID, %2$s: a status, %3$s: a form title (e.g. "42", "activated", "Contact Form") */ __( 'Lead #%1$d %2$s on "%3$s" form', 'stream' ), $lead_id, - $actions[ $status ], - $form['title'] + $this->escape_percentages( $actions[ $status ] ), + $this->get_form_title_for_message( $form ) ), array( 'lead_id' => $lead_id, @@ -782,16 +805,19 @@ public function callback_gform_update_status( $lead_id, $status, $prev = '' ) { public function callback_gform_update_is_read( $lead_id, $status ) { $lead = $this->get_lead( $lead_id ); $form = $this->get_form( $lead['form_id'] ); - $status = ( ! empty( $status ) ) ? esc_html__( 'read', 'stream' ) : esc_html__( 'unread', 'stream' ); $this->log( sprintf( /* translators: %1$d: a lead ID, %2$s: a status, %3$s: a form ID, %4$s: a form title (e.g. "42", "unread", "Contact Form") */ __( 'Entry #%1$d marked as %2$s on form #%3$d ("%4$s")', 'stream' ), $lead_id, - $status, + $this->get_status_for_message( + ! empty( $status ), + esc_html__( 'read', 'stream' ), + esc_html__( 'unread', 'stream' ) + ), $form['id'], - $form['title'] + $this->get_form_title_for_message( $form ) ), array( 'lead_id' => $lead_id, @@ -814,19 +840,23 @@ public function callback_gform_update_is_read( $lead_id, $status ) { * @param int $status Status. */ public function callback_gform_update_is_starred( $lead_id, $status ) { - $lead = $this->get_lead( $lead_id ); - $form = $this->get_form( $lead['form_id'] ); - $status = ( ! empty( $status ) ) ? esc_html__( 'starred', 'stream' ) : esc_html__( 'unstarred', 'stream' ); - $action = $status; + $lead = $this->get_lead( $lead_id ); + $form = $this->get_form( $lead['form_id'] ); + $status_for_message = $this->get_status_for_message( + ! empty( $status ), + esc_html__( 'starred', 'stream' ), + esc_html__( 'unstarred', 'stream' ) + ); + $action = $status_for_message; $this->log( sprintf( /* translators: %1$d: an ID, %2$s: a status, %3$d: a form title (e.g. "42", "starred", "Contact Form") */ __( 'Entry #%1$d %2$s on form #%3$d ("%4$s")', 'stream' ), $lead_id, - $status, + $status_for_message, // This has been escaped above. $form['id'], - $form['title'] + $this->get_form_title_for_message( $form ) ), array( 'lead_id' => $lead_id, @@ -945,8 +975,8 @@ public function log_form_action( $form_id, $action ) { /* translators: %1$d: an ID, %2$s: a form title, %3$s: a status (e.g. "42", "Contact Form", "Activated") */ __( 'Form #%1$d ("%2$s") %3$s', 'stream' ), $form_id, - $form['title'], - strtolower( $actions[ $action ] ) + $this->get_form_title_for_message( $form ), + strtolower( $this->escape_percentages( $actions[ $action ] ) ) ), array( 'form_id' => $form_id, @@ -976,4 +1006,45 @@ private function get_lead( $lead_id ) { private function get_form( $form_id ) { return \GFFormsModel::get_form_meta( $form_id ); } + + /** + * Get the name from an associative array with percentages escaped. + * To be used when calling $this->log(). + * + * @param array $data_array The array with a 'name' key to be escaped. + * @return string The name value with percentages escaped. + */ + private function get_name_for_message( $data_array ) { + if ( empty( $data_array['name'] ) ) { + return $this->escape_percentages( __( 'This does not have a name key', 'stream' ) ); + } + + return $this->escape_percentages( $data_array['name'] ); + } + + /** + * Get the form title from a form array with percentages escaped. + * To be used when calling $this->log(). + * + * @param array $form The form data array. + * @return string The title value with percentages escaped. + */ + private function get_form_title_for_message( $form ) { + if ( empty( $form['title'] ) ) { + return $this->escape_percentages( __( 'This does not have a title key', 'stream' ) ); + } + + return $this->escape_percentages( $form['title'] ); + } + + /** + * Get the status to use in a message with percentages in translation escaped. + * + * @param bool $conditional Whether or not it's a new form. + * @return string The status with percentages escaped. + */ + private function get_status_for_message( $conditional, $true_string, $false_string ) { + $status = $conditional ? $true_string : $false_string; + return $this->escape_percentages( $status ); + } } diff --git a/tests/testcase.php b/tests/testcase.php index 4d7df0532..ecd10e51f 100644 --- a/tests/testcase.php +++ b/tests/testcase.php @@ -15,6 +15,13 @@ class WP_StreamTestCase extends \WP_Ajax_UnitTestCase { */ protected $action_prefix = 'wp_stream_test_'; + /** + * Holds the mocked class. + * + * @var MockBuilder + */ + protected $mock; + /** * PHP unit setup function * diff --git a/tests/tests/connectors/test-class-connector-wordpress-seo.php b/tests/tests/connectors/test-class-connector-wordpress-seo.php index b9a5fa271..ef098bb27 100644 --- a/tests/tests/connectors/test-class-connector-wordpress-seo.php +++ b/tests/tests/connectors/test-class-connector-wordpress-seo.php @@ -27,7 +27,7 @@ public function setUp(): void { // Make partial of Connector_WordPress_SEO class, with mocked "log" function. $this->mock = $this->getMockBuilder( Connector_WordPress_SEO::class ) - ->setMethods( array( 'log' ) ) + ->onlyMethods( array( 'log' ) ) ->getMock(); // Register connector. From 11f8904e9b4dd39294f90055fdba5ba63644cf42 Mon Sep 17 00:00:00 2001 From: JJ Date: Thu, 18 Jul 2024 13:07:31 -0400 Subject: [PATCH 4/6] add params to docblock, formatted file --- connectors/class-connector-gravityforms.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/connectors/class-connector-gravityforms.php b/connectors/class-connector-gravityforms.php index a02c0d9e3..034bbcda0 100644 --- a/connectors/class-connector-gravityforms.php +++ b/connectors/class-connector-gravityforms.php @@ -803,8 +803,8 @@ public function callback_gform_update_status( $lead_id, $status, $prev = '' ) { * @param string $status Status. */ public function callback_gform_update_is_read( $lead_id, $status ) { - $lead = $this->get_lead( $lead_id ); - $form = $this->get_form( $lead['form_id'] ); + $lead = $this->get_lead( $lead_id ); + $form = $this->get_form( $lead['form_id'] ); $this->log( sprintf( @@ -847,7 +847,7 @@ public function callback_gform_update_is_starred( $lead_id, $status ) { esc_html__( 'starred', 'stream' ), esc_html__( 'unstarred', 'stream' ) ); - $action = $status_for_message; + $action = $status_for_message; $this->log( sprintf( @@ -1040,7 +1040,9 @@ private function get_form_title_for_message( $form ) { /** * Get the status to use in a message with percentages in translation escaped. * - * @param bool $conditional Whether or not it's a new form. + * @param bool $conditional Whether or not it's a new form. + * @param string $true_string The string to return when the conditional is true. + * @param string $false_string The string to return when the conditional is false. * @return string The status with percentages escaped. */ private function get_status_for_message( $conditional, $true_string, $false_string ) { From f9a22f5282e347342e3dac110a7cc00cc1b85741 Mon Sep 17 00:00:00 2001 From: JJ Date: Thu, 18 Jul 2024 13:30:22 -0400 Subject: [PATCH 5/6] more sensible name for npm test script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd775742a..7aee386ad 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "test": "npm-run-all test:*", "test:php": "npm run cli -- composer test --working-dir=wp-content/plugins/stream-src", "test:php-multisite": "npm run cli -- composer test-multisite --working-dir=wp-content/plugins/stream-src", - "test:php:one": "npm run cli -- composer test-one --working-dir=wp-content/plugins/stream-src --", + "test:php-one": "npm run cli -- composer test-one --working-dir=wp-content/plugins/stream-src --", "test-report": "npm run cli -- composer test-report --working-dir=wp-content/plugins/stream-src", "build-containers": "docker compose --file docker-compose.build.yml build", "push-containers": "docker compose --file docker-compose.build.yml push", From 09b0198c61ca4f7ea8743b13231429d7725f1ada Mon Sep 17 00:00:00 2001 From: Piotr Delawski Date: Fri, 19 Jul 2024 11:41:58 +0200 Subject: [PATCH 6/6] Fix `phpcs` issues --- .../connectors/test-class-connector-wordpress-seo.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/tests/connectors/test-class-connector-wordpress-seo.php b/tests/tests/connectors/test-class-connector-wordpress-seo.php index ef098bb27..246b53bd9 100644 --- a/tests/tests/connectors/test-class-connector-wordpress-seo.php +++ b/tests/tests/connectors/test-class-connector-wordpress-seo.php @@ -6,6 +6,7 @@ * * @package WP_Stream */ + namespace WP_Stream; class Test_WP_Stream_Connector_WordPress_SEO extends WP_StreamTestCase { @@ -69,9 +70,9 @@ public function test_callback_added_post_meta() { // Create post for later use. $post_id = wp_insert_post( array( - 'post_title' => 'Test post %!', - 'post_content' => 'Lorem ipsum dolor...', - 'post_status' => 'publish' + 'post_title' => 'Test post %!', + 'post_content' => 'Lorem ipsum dolor...', + 'post_status' => 'publish', ) );