From 7eaa118ab28ce4c914939acfea9a34176a99368e Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Sun, 26 Nov 2023 16:47:29 -0800 Subject: [PATCH] lint --- phpstan.neon | 14 ++++++++++++++ src/admin/class-plugins-page.php | 2 -- .../blockchain/class-bitcoin-api-contract-Test.php | 2 +- tests/unit/admin/class-plugins-page-unit-Test.php | 10 +++------- .../api/addresses/class-nimq-api-unit-Test.php | 2 +- tests/wpunit/frontend/class-ajax-wpunit-Test.php | 2 -- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 38e70b4..78cc0b5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -47,3 +47,17 @@ parameters: - '/does not accept default value of type array.{3}$/' # Sometimes seems to not find the test parent class's methods. # - '/Call to an undefined method.*(make|assert).*/' + # WC_Data::add_meta_data works fine with non-string/array values + - '/Parameter #2 \$value of method WC_Data::add_meta_data\(\) expects array\|string/' + - # + message: '#Parameter \#2 \$callback of static method WP_Mock::expect(Action|Filter)Added\(\) expects \(callable\(\): mixed\)\|Mockery\\Matcher\\Type, array{WP_Mock\\Matcher\\AnyInstance, .*} given.#' + path: tests/unit + - # Where we use Exceptions for control flow in tests, the return statements are absent. + message: '#Filter callback return statement is missing.#' + path: tests + - # Let's not check for null|false in tests. + message: '#\|(false|null) given#' + path: tests + - # Let's not check for null|false in tests. + message: '#does not accept .*\|null.#' + path: tests diff --git a/src/admin/class-plugins-page.php b/src/admin/class-plugins-page.php index fdb18b2..8ab805f 100644 --- a/src/admin/class-plugins-page.php +++ b/src/admin/class-plugins-page.php @@ -9,10 +9,8 @@ namespace BrianHenryIE\WP_Bitcoin_Gateway\Admin; -use BrianHenryIE\WP_Bitcoin_Gateway\API_Interface; use BrianHenryIE\WP_Bitcoin_Gateway\Settings_Interface; use BrianHenryIE\WP_Bitcoin_Gateway\WooCommerce\Bitcoin_Gateway; -use WC_Payment_Gateway; /** * Adds items to the plugin's row on plugins.php. diff --git a/tests/contract/api/blockchain/class-bitcoin-api-contract-Test.php b/tests/contract/api/blockchain/class-bitcoin-api-contract-Test.php index 92329d5..da09d13 100644 --- a/tests/contract/api/blockchain/class-bitcoin-api-contract-Test.php +++ b/tests/contract/api/blockchain/class-bitcoin-api-contract-Test.php @@ -26,7 +26,7 @@ public function get_bitcoin_apis(): array { $logger = new ColorLogger(); - $result[] = array( new Blockchain_Info_API( $logger ) ); + $result[] = array( new Blockchain_Info_Api( $logger ) ); $result[] = array( new Blockstream_Info_API( $logger ) ); return $result; diff --git a/tests/unit/admin/class-plugins-page-unit-Test.php b/tests/unit/admin/class-plugins-page-unit-Test.php index b369695..5c888e0 100644 --- a/tests/unit/admin/class-plugins-page-unit-Test.php +++ b/tests/unit/admin/class-plugins-page-unit-Test.php @@ -2,7 +2,6 @@ namespace BrianHenryIE\WP_Bitcoin_Gateway\Admin; -use BrianHenryIE\WP_Bitcoin_Gateway\API_Interface; use Codeception\Stub\Expected; use BrianHenryIE\WP_Bitcoin_Gateway\Settings_Interface; @@ -26,9 +25,8 @@ protected function tearDown(): void { */ public function test_add_settings_action_link(): void { - $api = $this->makeEmpty( API_Interface::class ); $settings = $this->makeEmpty( Settings_Interface::class ); - $sut = new Plugins_Page( $api, $settings ); + $sut = new Plugins_Page( $settings ); \WP_Mock::userFunction( 'is_plugin_active', @@ -68,8 +66,7 @@ public function test_add_settings_action_link(): void { public function test_add_settings_action_link_woocommerce_inactive(): void { $settings = $this->makeEmpty( Settings_Interface::class ); - $api = $this->makeEmpty( API_Interface::class ); - $sut = new Plugins_Page( $api, $settings ); + $sut = new Plugins_Page( $settings ); \WP_Mock::userFunction( 'is_plugin_active', @@ -110,8 +107,7 @@ public function test_split_author_link_into_two_links(): void { 'get_plugin_basename' => Expected::once( 'bh-wp-bitcoin-gateway/bh-wp-bitcoin-gateway.php' ), ) ); - $api = $this->makeEmpty( API_Interface::class ); - $sut = new Plugins_Page( $api, $settings ); + $sut = new Plugins_Page( $settings ); $plugin_meta = array( 0 => 'Version 1.3.3', diff --git a/tests/unit/api/addresses/class-nimq-api-unit-Test.php b/tests/unit/api/addresses/class-nimq-api-unit-Test.php index 8cbb360..0477def 100644 --- a/tests/unit/api/addresses/class-nimq-api-unit-Test.php +++ b/tests/unit/api/addresses/class-nimq-api-unit-Test.php @@ -5,7 +5,7 @@ use BrianHenryIE\ColorLogger\ColorLogger; /** - * @coversDefaultClass \BrianHenryIE\WP_Bitcoin_Gateway\API\Addresses\BitWasp_API + * @coversDefaultClass \BrianHenryIE\WP_Bitcoin_Gateway\API\Addresses\Nimq_API */ class Nimq_API_Unit_Test extends \Codeception\Test\Unit { diff --git a/tests/wpunit/frontend/class-ajax-wpunit-Test.php b/tests/wpunit/frontend/class-ajax-wpunit-Test.php index d4b8348..f58b3f9 100644 --- a/tests/wpunit/frontend/class-ajax-wpunit-Test.php +++ b/tests/wpunit/frontend/class-ajax-wpunit-Test.php @@ -59,8 +59,6 @@ public function test_omit_data(): void { 'wp_doing_ajax', function (): bool { throw new Exception(); - // phpcs:disable Squiz.PHP.NonExecutableCode.Unreachable - return false; } );