From 57a9a9ad810d49ad318637281a81d738699d2fb5 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Fri, 22 Jul 2022 17:09:12 +0530 Subject: [PATCH 1/9] enhancement/140 Bump WordPress and PHP minimums --- .github/workflows/cypress.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/php-compatibility.yml | 6 +++--- .github/workflows/test.yml | 5 +---- composer.json | 6 +++--- readme.txt | 4 ++-- simple-local-avatars.php | 4 ++-- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index ffc2adb0..fb66fcd2 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -12,7 +12,7 @@ jobs: matrix: core: - {name: 'WP latest', version: 'latest'} - - {name: 'WP minimum', version: 'WordPress/WordPress#4.9'} + - {name: 'WP minimum', version: 'WordPress/WordPress#5.7'} - {name: 'WP trunk', version: 'WordPress/WordPress#master'} steps: - name: Checkout diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1c6d66ab..6f14b593 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ jobs: - name: Set PHP version uses: shivammathur/setup-php@v2 with: - php-version: '7.3' + php-version: '7.4' tools: composer:v2 coverage: none diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 9264199e..cb484689 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -11,7 +11,7 @@ on: jobs: php_compatibility: - name: PHP minimum 5.6 + name: PHP minimum 7.4 runs-on: ubuntu-latest steps: @@ -21,7 +21,7 @@ jobs: - name: Set PHP version uses: shivammathur/setup-php@v2 with: - php-version: 7.2 + php-version: 7.4 tools: composer:v2 coverage: none @@ -29,4 +29,4 @@ jobs: run: composer update -W - name: Check PHP Compatibility - run: vendor/bin/phpcs simple-local-avatars.php includes/ --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 5.6- \ No newline at end of file + run: vendor/bin/phpcs simple-local-avatars.php includes/ --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 7.4- \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ec8bf10..5ada2ae6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,10 +31,7 @@ jobs: strategy: fail-fast: false matrix: - # We claim to support from 5.6+ but WP Mock only supports 7.1+ - # Also an issue with WP Mock not working on PHPUnit 9.5+, which PHP 7.3+ needs. - # php: [ '5.6', '7.0', '7.4', '8.0', '8.1' ] - php: [ '7.1', '7.2' ] + php: [ '7.4', '8.0', '8.1' ] steps: - name: Checkout diff --git a/composer.json b/composer.json index 2b31f032..a2d50f1e 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "source": "https://github.com/10up/simple-local-avatars" }, "require": { - "php": ">=5.6" + "php": ">=7.4" }, "require-dev": { "10up/phpcs-composer": "dev-master", @@ -28,12 +28,12 @@ }, "scripts": { "lint": [ - "phpcs . --runtime-set testVersion 5.6-" + "phpcs . --runtime-set testVersion 7.4-" ], "lint-fix": [ "phpcbf ." ], - "phpcs:compat": "vendor/bin/phpcs simple-local-avatars.php includes --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 5.6-" + "phpcs:compat": "vendor/bin/phpcs simple-local-avatars.php includes --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 7.4-" }, "minimum-stability": "dev" } diff --git a/readme.txt b/readme.txt index a2dbb278..98cb0e73 100644 --- a/readme.txt +++ b/readme.txt @@ -2,9 +2,9 @@ Contributors: jakemgold, 10up, thinkoomph, jeffpaul, faisal03 Donate link: https://10up.com/plugins/simple-local-avatars-wordpress/ Tags: avatar, gravatar, user photos, users, profile -Requires at least: 4.6 +Requires at least: 5.7 Tested up to: 6.0 -Requires PHP: 5.6 +Requires PHP: 7.4 Stable tag: 2.5.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/simple-local-avatars.php b/simple-local-avatars.php index f0212740..c279b427 100644 --- a/simple-local-avatars.php +++ b/simple-local-avatars.php @@ -4,8 +4,8 @@ * Plugin URI: https://10up.com/plugins/simple-local-avatars-wordpress/ * Description: Adds an avatar upload field to user profiles. Generates requested sizes on demand, just like Gravatar! Simple and lightweight. * Version: 2.5.0 - * Requires at least: 4.6 - * Requires PHP: 5.6 + * Requires at least: 5.7 + * Requires PHP: 7.4 * Author: Jake Goldman, 10up * Author URI: https://10up.com * License: GPLv2 or later From 89fdc51456aff15020d1b01863550cad17afd06b Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Fri, 22 Jul 2022 17:23:42 +0530 Subject: [PATCH 2/9] fix for deprecated schema: Warning: Your XML configuration validates against a deprecated schema. Suggestion: Migrate your XML configuration using "--migrate-configuration"! --- phpunit.xml | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 46b27c9b..101f80af 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,23 +1,20 @@ - - - - ./tests/phpunit - tests/phpunit/multisite - - - - - includes - - - - - - - - + + + + + includes + + + + + + ./tests/phpunit + tests/phpunit/multisite + + + + + + + From 0e17708b2e4cf9cc82428c57195cdda334736ae6 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Fri, 22 Jul 2022 17:28:54 +0530 Subject: [PATCH 3/9] trying to fix PHPUnit version compatibility issue > PHPUnit 9.5.21 #StandWithUkraine > EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 30 / 30 (100%) --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ada2ae6..ec87be23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '7.4', '8.0', '8.1' ] + php: [ '7.1', '7.2' ] steps: - name: Checkout From 0712ba02be6a580f8016e2fadf4b7d12f70cd7df Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Fri, 22 Jul 2022 17:31:27 +0530 Subject: [PATCH 4/9] Downgrading min php version to fix phpunit test failures - Root composer.json requires php >=7.4 but your php version (7.1.33) does not satisfy that requirement. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a2d50f1e..ea72ab32 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "source": "https://github.com/10up/simple-local-avatars" }, "require": { - "php": ">=7.4" + "php": ">=7.1" }, "require-dev": { "10up/phpcs-composer": "dev-master", From c46a7337186d93b34c21358400f48b70fd8e8a5c Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Wed, 10 Aug 2022 16:20:05 +0530 Subject: [PATCH 5/9] upgrading to `7.4` after noticing the PHPUnit failure is already addressed in the upstream: https://github.com/10up/wp_mock/pull/164 --- .github/workflows/test.yml | 17 +---------------- composer.json | 2 +- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec87be23..2246fdc9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,28 +10,13 @@ on: - develop jobs: -# test_wpa: -# runs-on: ubuntu-latest -# -# steps: -# - name: Checkout -# uses: actions/checkout@v2 -# - name: Set PHP version -# uses: shivammathur/setup-php@v1 -# with: -# php-version: '7.2' -# coverage: none -# -# - name: Install dependencies -# run: composer install - phpunit: name: ${{ matrix.php }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: [ '7.1', '7.2' ] + php: [ '7.4', '8.0' ] steps: - name: Checkout diff --git a/composer.json b/composer.json index ea72ab32..a2d50f1e 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "source": "https://github.com/10up/simple-local-avatars" }, "require": { - "php": ">=7.1" + "php": ">=7.4" }, "require-dev": { "10up/phpcs-composer": "dev-master", From 2b8e16054e6cf9322728cd2fe8aaff0de04d7231 Mon Sep 17 00:00:00 2001 From: Max Lyuchin Date: Thu, 18 Aug 2022 11:16:13 +0300 Subject: [PATCH 6/9] Fix all tests failure --- tests/phpunit/SimpleLocalAvatarsTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/SimpleLocalAvatarsTest.php b/tests/phpunit/SimpleLocalAvatarsTest.php index 1395a75c..a745d2c5 100644 --- a/tests/phpunit/SimpleLocalAvatarsTest.php +++ b/tests/phpunit/SimpleLocalAvatarsTest.php @@ -4,7 +4,7 @@ class SimpleLocalAvatarsTest extends \WP_Mock\Tools\TestCase { private $instance; public function setUp(): void { - parent::setUp(); + \WP_Mock::setUp(); $this->instance = Mockery::mock( 'Simple_Local_Avatars' )->makePartial(); @@ -75,7 +75,7 @@ public function tearDown(): void { $this->addToAssertionCount( Mockery::getContainer()->mockery_getExpectationCount() ); - parent::tearDown(); + \WP_Mock::tearDown(); } public function test_add_hooks() { From 971021d497979d048dd5208e2332610c62f27a97 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Fri, 19 Aug 2022 19:08:18 +0530 Subject: [PATCH 7/9] fix phpunit test failures after fixing the getAnnotation error --- tests/phpunit/SimpleLocalAvatarsTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/SimpleLocalAvatarsTest.php b/tests/phpunit/SimpleLocalAvatarsTest.php index a745d2c5..2f24978d 100644 --- a/tests/phpunit/SimpleLocalAvatarsTest.php +++ b/tests/phpunit/SimpleLocalAvatarsTest.php @@ -165,7 +165,7 @@ public function test_plugin_filter_action_links() { $this->assertNotEmpty( $action_links ); $this->assertArrayHasKey( 'settings', $action_links ); - $this->assertContains( 'options-discussion.php', $action_links['settings'] ); + $this->assertStringContainsString( 'options-discussion.php', $action_links['settings'] ); } public function test_get_avatar_data() { @@ -301,11 +301,11 @@ public function test_avatar_settings_field() { WP_Mock::userFunction( 'checked' ) ->andReturn( 'checked' ); - $expected = ''; - - $this->expectOutputString( $expected ); - + ob_start(); $this->instance->avatar_settings_field( $args ); + $output = ob_get_clean(); + + $this->assertStringContainsString( 'This is a description.', $output ); } public function test_edit_user_profile() { @@ -329,11 +329,11 @@ public function test_edit_user_profile() { $profileuser = new stdClass(); $profileuser->ID = 1; - $expected = '

Avatar

Choose an image from your computer:

Rating
Rating



If the local avatar is inappropriate for this site, Gravatar will be attempted.

'; - - $this->expectOutputString( $expected ); - + ob_start(); $this->instance->edit_user_profile( $profileuser ); + $output = ob_get_clean(); + + $this->assertStringContainsString( 'Choose an image from your computer', $output ); } public function test_assign_new_user_avatar() { From 916a8e6ef66cfaa3a66e57b8f8b798249c9fb571 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Fri, 19 Aug 2022 19:10:33 +0530 Subject: [PATCH 8/9] trying to fix: 1) SimpleLocalAvatarsNetworkTest::test_is_network Error: Call to undefined method SimpleLocalAvatarsNetworkTest::getAnnotations() https://github.com/10up/simple-local-avatars/runs/7919270614?check_suite_focus=true --- tests/phpunit/SimpleLocalAvatarsTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/SimpleLocalAvatarsTest.php b/tests/phpunit/SimpleLocalAvatarsTest.php index 2f24978d..6130f09e 100644 --- a/tests/phpunit/SimpleLocalAvatarsTest.php +++ b/tests/phpunit/SimpleLocalAvatarsTest.php @@ -106,12 +106,12 @@ public function test_add_hooks() { } public function test_is_network() { - WP_Mock::userFunction( 'get_site_option', [ + \WP_Mock::userFunction( 'get_site_option', [ 'args' => [ 'active_sitewide_plugins', [] ], 'return' => [], 'times' => 1, ] ); - WP_Mock::userFunction( 'is_multisite', [ + \WP_Mock::userFunction( 'is_multisite', [ 'return' => false, 'times' => 1, ] ); From 021c85c51f4d8af0e4259abed3c86828eb1e7262 Mon Sep 17 00:00:00 2001 From: faisal-alvi Date: Fri, 19 Aug 2022 19:14:10 +0530 Subject: [PATCH 9/9] fix `getAnnotations` error for multisite tests https://github.com/10up/simple-local-avatars/runs/7919310499?check_suite_focus=true --- tests/phpunit/SimpleLocalAvatarsTest.php | 4 ++-- tests/phpunit/multisite/SimpleLocalAvatarsNetworkTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/SimpleLocalAvatarsTest.php b/tests/phpunit/SimpleLocalAvatarsTest.php index 6130f09e..2f24978d 100644 --- a/tests/phpunit/SimpleLocalAvatarsTest.php +++ b/tests/phpunit/SimpleLocalAvatarsTest.php @@ -106,12 +106,12 @@ public function test_add_hooks() { } public function test_is_network() { - \WP_Mock::userFunction( 'get_site_option', [ + WP_Mock::userFunction( 'get_site_option', [ 'args' => [ 'active_sitewide_plugins', [] ], 'return' => [], 'times' => 1, ] ); - \WP_Mock::userFunction( 'is_multisite', [ + WP_Mock::userFunction( 'is_multisite', [ 'return' => false, 'times' => 1, ] ); diff --git a/tests/phpunit/multisite/SimpleLocalAvatarsNetworkTest.php b/tests/phpunit/multisite/SimpleLocalAvatarsNetworkTest.php index ebe38688..1b619bf8 100644 --- a/tests/phpunit/multisite/SimpleLocalAvatarsNetworkTest.php +++ b/tests/phpunit/multisite/SimpleLocalAvatarsNetworkTest.php @@ -4,7 +4,7 @@ class SimpleLocalAvatarsNetworkTest extends \WP_Mock\Tools\TestCase { private $instance; public function setUp(): void { - parent::setUp(); + \WP_Mock::setUp(); $this->instance = Mockery::mock( 'Simple_Local_Avatars' )->makePartial();