Skip to content

Commit

Permalink
Merge pull request #202 from Kit/tests-use-phpstan-2.0
Browse files Browse the repository at this point in the history
Tests: Use PHPStan 2.0
  • Loading branch information
n7studios authored Dec 10, 2024
2 parents c74acce + b8ef132 commit b08a3df
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
DB_PASS: root
DB_HOST: localhost
INSTALL_PLUGINS: "custom-order-numbers-for-woocommerce woocommerce woocommerce-gateway-stripe" # Don't include this repository's Plugin here.
INSTALL_PLUGINS_URLS: "http://cktestplugins.wpengine.com/wp-content/uploads/2024/11/disable-doing-it-wrong-notices.zip" # URLs to specific third party Plugins
STRIPE_TEST_PUBLISHABLE_KEY: ${{ secrets.STRIPE_TEST_PUBLISHABLE_KEY }} # Stripe Test API Publishable Key, stored in the repository's Settings > Secrets
STRIPE_TEST_SECRET_KEY: ${{ secrets.STRIPE_TEST_SECRET_KEY }} # Stripe Test API Secret Key, stored in the repository's Settings > Secrets
CONVERTKIT_API_KEY: ${{ secrets.CONVERTKIT_API_KEY }} # ConvertKit API Key, stored in the repository's Settings > Secrets
Expand Down Expand Up @@ -126,6 +127,11 @@ jobs:
working-directory: ${{ env.ROOT_DIR }}
run: wp-cli plugin install ${{ env.INSTALL_PLUGINS }} --activate

# env.INSTALL_PLUGINS_URLS is a list of Plugin URLs, space separated, to install specific versions ot third party Plugins.
- name: Install Free Third Party WordPress Specific Version Plugins
working-directory: ${{ env.ROOT_DIR }}
run: wp-cli plugin install ${{ env.INSTALL_PLUGINS_URLS }}

# These should be stored as a separated list of URLs in the repository Settings > Secrets > Repository Secret > CONVERTKIT_PAID_PLUGIN_URLS.
# We cannot include the URLs in this file, as they're not Plugins we are permitted to distribute.
- name: Install Paid Third Party WordPress Plugins
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"codeception/util-universalframework": "^1.0",
"php-webdriver/webdriver": "^1.0",
"wp-coding-standards/wpcs": "^3.0.0",
"phpstan/phpstan": "^1.7",
"szepeviktor/phpstan-wordpress": "^1.0",
"wp-cli/wp-cli-bundle": "2.9.0"
"phpstan/phpstan": "^1.0 || ^2.0",
"szepeviktor/phpstan-wordpress": "^1.0 || ^2.0",
"wp-cli/wp-cli-bundle": "2.11"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
3 changes: 0 additions & 3 deletions includes/class-ckwc-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,6 @@ private function maybe_import_configuration() {
global $wp_filesystem;

// Bail if no configuration file was supplied.
if ( ! is_array( $_FILES ) ) {
return;
}
if ( ! array_key_exists( 'woocommerce_ckwc_import', $_FILES ) ) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ parameters:
scanDirectories:
- /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-content/plugins

# Location of constants for PHPStan to scan, building symbols.
scanFiles:
- /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-config.php

# Should not need to edit anything below here
# Rule Level: https://phpstan.org/user-guide/rule-levels
level: 5
Expand Down
8 changes: 6 additions & 2 deletions phpstan.neon.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PHPStan configuration for local static analysis.
# PHPStan configuration for GitHub Actions.

# Include PHPStan for WordPress configuration.
includes:
Expand All @@ -19,7 +19,11 @@ parameters:

# Location of WordPress Plugins for PHPStan to scan, building symbols.
scanDirectories:
- /Users/tim/Local Sites/convertkit-github/app/public/wp-content/plugins
- /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-content/plugins

# Location of constants for PHPStan to scan, building symbols.
scanFiles:
- /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-config.php

# Should not need to edit anything below here
# Rule Level: https://phpstan.org/user-guide/rule-levels
Expand Down
5 changes: 5 additions & 0 deletions tests/_support/Helper/Acceptance/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function deactivateConvertKitPlugin($I)
*/
public function activateWooCommerceAndConvertKitPlugins($I)
{
// Activate Disable _load_textdomain notice.
$I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice');

// Activate ConvertKit Plugin.
$I->activateConvertKitPlugin($I);

Expand Down Expand Up @@ -78,6 +81,8 @@ public function deactivateWooCommerceAndConvertKitPlugins($I)
// Deactivate WooCommerce Stripe Gateway before WooCommerce, to prevent WooCommerce throwing a fatal error.
$I->deactivateThirdPartyPlugin($I, 'woocommerce-gateway-stripe');
$I->deactivateThirdPartyPlugin($I, 'woocommerce');

$I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice');
}

/**
Expand Down

0 comments on commit b08a3df

Please sign in to comment.