Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/140 Bump WordPress and PHP minimums #143

Merged
merged 9 commits into from
Aug 22, 2022
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
php_compatibility:
name: PHP minimum 5.6
name: PHP minimum 7.4
runs-on: ubuntu-latest

steps:
Expand All @@ -21,12 +21,12 @@ jobs:
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
php-version: 7.4
tools: composer:v2
coverage: none

- name: Install dependencies
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-
run: vendor/bin/phpcs simple-local-avatars.php includes/ --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 7.4-
20 changes: 1 addition & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +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:
# 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' ]

steps:
- name: Checkout
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
41 changes: 19 additions & 22 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<phpunit
bootstrap="tests/phpunit/bootstrap.php"
backupGlobals="false"
processIsolation="false"
colors="false">
<testsuites>
<testsuite name="Simple Local Avatars">
<directory suffix="Test.php">./tests/phpunit</directory>
<exclude>tests/phpunit/multisite</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">includes</directory>
<exclude></exclude>
</whitelist>
</filter>
<php>
<ini name="error_reporting" value="32767" />
<ini name="display_errors" value="1" />
<ini name="display_startup_errors" value="1" />
</php>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/phpunit/bootstrap.php" backupGlobals="false" processIsolation="false" colors="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">includes</directory>
</include>
<exclude/>
</coverage>
<testsuites>
<testsuite name="Simple Local Avatars">
<directory suffix="Test.php">./tests/phpunit</directory>
<exclude>tests/phpunit/multisite</exclude>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="32767"/>
<ini name="display_errors" value="1"/>
<ini name="display_startup_errors" value="1"/>
</php>
</phpunit>
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions simple-local-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions tests/phpunit/SimpleLocalAvatarsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -75,7 +75,7 @@ public function tearDown(): void {
$this->addToAssertionCount(
Mockery::getContainer()->mockery_getExpectationCount()
);
parent::tearDown();
\WP_Mock::tearDown();
}

public function test_add_hooks() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -301,11 +301,11 @@ public function test_avatar_settings_field() {
WP_Mock::userFunction( 'checked' )
->andReturn( 'checked' );

$expected = '<label for="simple-local-avatars-shared"><input type="checkbox" name="simple_local_avatars[shared]" id="simple-local-avatars-shared" value="1" checked />This is a description.</label>';

$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() {
Expand All @@ -329,11 +329,11 @@ public function test_edit_user_profile() {
$profileuser = new stdClass();
$profileuser->ID = 1;

$expected = '<div id="simple-local-avatar-section"><h3>Avatar</h3><table class="form-table"><tr class="upload-avatar-row"><th scope="row"><label for="simple-local-avatar">Upload Avatar</label></th><td style="width: 50px;" id="simple-local-avatar-photo"><img src="test-image-user-avatar"/></td><td><p style="display: inline-block; width: 26em;"><span class="description">Choose an image from your computer:</span><br /><input type="file" name="simple-local-avatar" id="simple-local-avatar" class="standard-text" /><span class="spinner" id="simple-local-avatar-spinner"></span></p><p><a href="" class="button item-delete submitdelete deletion" id="simple-local-avatar-remove" style="display:none;">Delete local avatar</a></p></td></tr><tr class="ratings-row"><th scope="row">Rating</th><td colspan="2"><fieldset id="simple-local-avatar-ratings" ><legend class="screen-reader-text"><span>Rating</span></legend><label><input type=\'radio\' name=\'simple_local_avatar_rating\' value=\'G\' />G &#8212; Suitable for all audiences</label><br /><label><input type=\'radio\' name=\'simple_local_avatar_rating\' value=\'PG\' />PG &#8212; Possibly offensive, usually for audiences 13 and above</label><br /><label><input type=\'radio\' name=\'simple_local_avatar_rating\' value=\'R\' />R &#8212; Intended for adult audiences above 17</label><br /><label><input type=\'radio\' name=\'simple_local_avatar_rating\' value=\'X\' />X &#8212; Even more mature than above</label><br /><p class="description">If the local avatar is inappropriate for this site, Gravatar will be attempted.</p></fieldset></td></tr></table></div>';

$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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down