From a6522c211ea3608025d7790cd1435e7eeec32540 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Tue, 14 Jan 2025 10:27:17 +0100 Subject: [PATCH] update phpunit config to convert deprecations to errors; remove brain/monkey dependency --- composer.json | 8 ++------ mailchimp-for-wp.php | 9 +++++---- phpunit.xml.dist | 33 ++++++++++++++++++-------------- tests/DebugLogReaderTest.php | 2 +- tests/IntegrationManagerTest.php | 2 +- tests/IntegrationTest.php | 2 ++ tests/QueueTest.php | 15 --------------- tests/bootstrap.php | 5 ++--- tests/mock.php | 33 ++++++++++++++++++++------------ 9 files changed, 53 insertions(+), 56 deletions(-) diff --git a/composer.json b/composer.json index 760c52d0..87a11d0c 100755 --- a/composer.json +++ b/composer.json @@ -21,8 +21,7 @@ "php": ">=7.4" }, "require-dev": { - "phpunit/phpunit": "^9.0", - "brain/monkey": "^2.2", + "phpunit/phpunit": "^9.6", "squizlabs/php_codesniffer": "^3.11" }, "scripts": { @@ -30,8 +29,5 @@ "test": "phpunit tests/", "codestyle": "phpcs -n -s", "check-syntax": "./bin/check-php-syntax" - }, - "config": { - }, - "minimum-stability": "dev" + } } diff --git a/mailchimp-for-wp.php b/mailchimp-for-wp.php index 3145a1c7..f3fc8a99 100755 --- a/mailchimp-for-wp.php +++ b/mailchimp-for-wp.php @@ -32,10 +32,6 @@ // Prevent direct file access defined('ABSPATH') or exit; -// don't run if PHP version is lower than 7.4.0 -if (PHP_VERSION_ID < 70400) { - return; -} /** @ignore */ function _mc4wp_load_plugin() @@ -47,6 +43,11 @@ function _mc4wp_load_plugin() return; } + // don't run if PHP version is lower than 7.4.0 + if (PHP_VERSION_ID < 70400) { + return; + } + // bootstrap the core plugin define('MC4WP_VERSION', '4.9.21'); define('MC4WP_PLUGIN_DIR', __DIR__); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 19ca06dc..2af3f3f2 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,21 @@ - - - - ./src - - - - - ./tests/ - - - - - + + + + + + + + + + + + tests + + diff --git a/tests/DebugLogReaderTest.php b/tests/DebugLogReaderTest.php index 8f8fe023..def5d82b 100755 --- a/tests/DebugLogReaderTest.php +++ b/tests/DebugLogReaderTest.php @@ -13,7 +13,7 @@ class DebugLogReaderTest extends TestCase /** * @var string */ - protected $sample_log_lines = array( + protected array $sample_log_lines = array( 'eCommerce360 > Successfully added order 101', 'eCommerce360 > Order 101 deleted', ); diff --git a/tests/IntegrationManagerTest.php b/tests/IntegrationManagerTest.php index 054690f5..69c04885 100755 --- a/tests/IntegrationManagerTest.php +++ b/tests/IntegrationManagerTest.php @@ -62,7 +62,7 @@ public function test_get() $instance->register_integration('slug', 'MC4WP_Sample_Integration', true); - self::expectException(null); + self::expectException(''); self::assertInstanceOf('MC4WP_Sample_Integration', $instance->get('slug')); } } diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index c4eca748..24d3adde 100755 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -30,6 +30,8 @@ public function test_constructor() public function test_checkbox_was_checked() { $slug = 'my-integration'; + + /** @var MC4WP_Integration $instance */ $instance = $this->getMockForAbstractClass('MC4WP_Integration', array( $slug, array() diff --git a/tests/QueueTest.php b/tests/QueueTest.php index a1fba2d8..9989ad74 100755 --- a/tests/QueueTest.php +++ b/tests/QueueTest.php @@ -1,23 +1,9 @@ put(array( 'key' => 'value' )); - Functions\when('update_option')->justReturn(true); self::assertTrue($queue->save()); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index fb59ad58..5836d04b 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,6 @@ echo 'Welcome to the Mailchimp for WordPress Test Suite' . PHP_EOL; -require __DIR__ . '/../autoload.php'; -require __DIR__ . '/../vendor/antecedent/patchwork/Patchwork.php'; require __DIR__ . '/mock.php'; -require __DIR__ . '/../vendor/autoload.php'; + +require dirname(__DIR__) . '/autoload.php'; diff --git a/tests/mock.php b/tests/mock.php index 506de6b3..08d4eefa 100755 --- a/tests/mock.php +++ b/tests/mock.php @@ -1,13 +1,17 @@ 1, @@ -119,7 +128,7 @@ function mock_post(array $props) : WP_Post ), $props ); - foreach($props as $key => $value) { + foreach ($props as $key => $value) { $post->$key = $value; }