From 53a6e267aab44e463a6229b8d209099bcb03753a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 10:28:39 +0200 Subject: [PATCH] fix phpcs tests --- .forgejo/workflows/phpcs.yml | 7 +- .phpcs.xml.dist | 176 ++++++++++++++---- activitypub-event-extensions.php | 8 +- .../transformer/class-events-manager.php | 2 + .../transformer/class-gatherpress.php | 2 + includes/admin/class-settings-page.php | 2 +- phpunit.xml.dist => phpunit.xml | 0 templates/settings.php | 4 +- 8 files changed, 158 insertions(+), 43 deletions(-) rename phpunit.xml.dist => phpunit.xml (100%) diff --git a/.forgejo/workflows/phpcs.yml b/.forgejo/workflows/phpcs.yml index 6d24ee2..4db1ac5 100755 --- a/.forgejo/workflows/phpcs.yml +++ b/.forgejo/workflows/phpcs.yml @@ -1,4 +1,5 @@ -name: Unit Testing +name: PHP Code Checker + on: push: branches: @@ -6,7 +7,7 @@ on: pull_request: jobs: - phpunit: + phpcs: runs-on: ubuntu-latest services: mysql: @@ -16,7 +17,7 @@ jobs: strategy: matrix: php-versions: ['8.1'] - name: Run phpunit tests + name: Run PHP Code Checker env: extensions: mysql key: cache-v1 diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index df58068..d7cc4f5 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -1,47 +1,157 @@ - - Generally-applicable sniffs for WordPress plugins. + + + A custom set of rules to check for a WPized WordPress project + + - . - /vendor/ - /node_modules/ - - - - - - - - + + /docroot/wp-admin/* + /docroot/wp-includes/* + /docroot/wp-*.php + /docroot/index.php + /docroot/xmlrpc.php + /docroot/wp-content/plugins/* - - - - - + + /vendor/* - - - - - - - - - - + + /node_modules/* + + + *.min.js + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + - + + - + + + - + + + + + + + tests/*.php + templates/*.php + + + tests/*.php + + + tests/*.php + + + \ No newline at end of file diff --git a/activitypub-event-extensions.php b/activitypub-event-extensions.php index 392601a..d106516 100644 --- a/activitypub-event-extensions.php +++ b/activitypub-event-extensions.php @@ -44,7 +44,7 @@ Activitypub_Event_Extensions\Setup::get_instance(); * * @todo This filter is temporary code needed to do local testing. */ -add_filter( 'http_request_host_is_external', 'custom_http_request_host_is_external', 10, 3 ); +add_filter( 'http_request_host_is_external', 'activitypub_event_extensions_custom_http_request_host_is_external', 10, 3 ); /** * Add a filter for http_request_host_is_external @@ -55,7 +55,7 @@ add_filter( 'http_request_host_is_external', 'custom_http_request_host_is_extern * * @todo This filter is temporary code needed to do local testing. */ -function custom_http_request_host_is_external( $is_external ) { +function activitypub_event_extensions_custom_http_request_host_is_external( $is_external ) { $is_external = true; return $is_external; @@ -68,11 +68,11 @@ function custom_http_request_host_is_external( $is_external ) { * * @todo This filter is temporary code needed to do local testing. */ -add_filter( 'https_ssl_verify', 'dont_verify_local_dev_https', 10, 3 ); +add_filter( 'https_ssl_verify', 'activitypub_event_extensions_dont_verify_local_dev_https', 10, 3 ); /** * TODO: remove it. */ -function dont_verify_local_dev_https() { +function activitypub_event_extensions_dont_verify_local_dev_https() { return false; } diff --git a/includes/activitypub/transformer/class-events-manager.php b/includes/activitypub/transformer/class-events-manager.php index e6b52bd..4cbc71d 100644 --- a/includes/activitypub/transformer/class-events-manager.php +++ b/includes/activitypub/transformer/class-events-manager.php @@ -6,6 +6,8 @@ * @license AGPL-3.0-or-later */ +namespace Activitypub_Event_Extensions\Activitypub\Transformer; + use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer; use EM_Event; use Activitypub\Activity\Extended_Object\Event; diff --git a/includes/activitypub/transformer/class-gatherpress.php b/includes/activitypub/transformer/class-gatherpress.php index c875ed1..d04e4a6 100644 --- a/includes/activitypub/transformer/class-gatherpress.php +++ b/includes/activitypub/transformer/class-gatherpress.php @@ -6,6 +6,8 @@ * @license AGPL-3.0-or-later */ +namespace Activitypub_Event_Extensions\Activitypub\Transformer; + use Activitypub_Event_Extensions\Activitypub\Transformer\Event; use Activitypub\Model\Blog; use Activitypub\Activity\Extended_Object\Event as Event_Object; diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php index dbe5ed5..d7cc288 100644 --- a/includes/admin/class-settings-page.php +++ b/includes/admin/class-settings-page.php @@ -37,7 +37,7 @@ class Settings_Page { public static function admin_menu(): void { \add_options_page( 'Activitypub Event Extension', - __( 'ActivityPub Events', 'activitypub_event_extensions' ), + __( 'ActivityPub Events', 'activitypub-event-extensions' ), 'manage_options', self::SETTINGS_SLUG, array( self::STATIC, 'settings_page' ) diff --git a/phpunit.xml.dist b/phpunit.xml similarity index 100% rename from phpunit.xml.dist rename to phpunit.xml diff --git a/templates/settings.php b/templates/settings.php index aab3640..df52492 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -76,7 +76,7 @@ $current_category_mapping = \get_option( 'activitypub_event_extensions_ev

-

+

@@ -96,7 +96,7 @@ $current_category_mapping = \get_option( 'activitypub_event_extensions_ev

-

+