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

Add PHPUnit tests workflow for multisite #7321

Merged
merged 38 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
903956c
Add PHP version in wp-env config
thelovekesh Nov 1, 2022
16b6c9e
Add workflow to run PHP unit tests on multisite
thelovekesh Nov 1, 2022
cdb9dca
Add npm script to run PHP unit tests on multisite
thelovekesh Nov 1, 2022
f8572bd
Fix yml syntax error
thelovekesh Nov 1, 2022
d6a69d2
Remove skip condition from multisite unit tests workflow for testing
thelovekesh Nov 1, 2022
e01869e
Use phpunit from vendor
thelovekesh Nov 1, 2022
8997b11
Move tests with base dir as amp
thelovekesh Nov 1, 2022
533d940
Fix base dir path errors
thelovekesh Nov 1, 2022
91cb0d1
Add matrix to run different testsuites
thelovekesh Nov 1, 2022
ac70da5
Fix yml syntax error
thelovekesh Nov 1, 2022
b84213d
Merge branch 'develop' into add/multisite-phpunit-workflow
thelovekesh Nov 21, 2022
6c1ef34
Update test_amp_get_content_sanitizers_with_dev_mode for multisite en…
thelovekesh Nov 21, 2022
ce73a7c
Update test_amp_has_paired_endpoint_go_to for multisite environment
thelovekesh Nov 21, 2022
182993d
Update test_get_amp_compatible_plugins_url to have super admin access…
thelovekesh Nov 21, 2022
1a6301c
Update test cases in ReaderThemesTest to have super admin access in m…
thelovekesh Nov 21, 2022
e4fc60d
Update SiteHealthTest::test_register_async_test_endpoints to have sup…
thelovekesh Nov 21, 2022
9bddbeb
Update SupportLinkTest::test_is_needed to have super admin access in …
thelovekesh Nov 21, 2022
e195625
Update SupportScreenTest::test_is_needed to have super admin access i…
thelovekesh Nov 21, 2022
c7fcac6
Update UserRESTEndpointExtensionTest::test_update_review_panel_dismis…
thelovekesh Nov 21, 2022
18d3c7b
Update ReaderThemeLoaderTest::test_filter_wp_prepare_themes_to_indica…
thelovekesh Nov 21, 2022
2f8c7a7
Update Test_Uninstall::test_remove_plugin_data to calculate correct D…
thelovekesh Nov 21, 2022
69649ae
Remove vague variable decleration
thelovekesh Nov 21, 2022
c7b25be
Remove vague inline comment
thelovekesh Nov 21, 2022
14f78ef
Add workaround for cdata_malformed_utf8_json test
westonruter Nov 21, 2022
0d82ad0
Fix comments indentation
thelovekesh Nov 23, 2022
de04a69
Add trait for mocking admin and super admin user
thelovekesh Nov 23, 2022
4dc01a4
Update admin and super admin user mocking with helper MockAdminUser t…
thelovekesh Nov 23, 2022
6b4d87f
Merge branch 'develop' into add/multisite-phpunit-workflow
thelovekesh Nov 23, 2022
83b5304
Remove comment from job condition
thelovekesh Nov 23, 2022
c533fc1
Add steps to update PHPUnit version
thelovekesh Nov 23, 2022
88fb246
Revert quote_type to single
thelovekesh Nov 23, 2022
deb6e3c
Update deprecated set-output commands with GITHUB_OUTPUT environment …
thelovekesh Nov 23, 2022
ad687db
Add inline comment for switching blogs in multisite tests
thelovekesh Nov 24, 2022
56cb572
Update mock_admin_user() to return WP_User object
thelovekesh Nov 24, 2022
74771af
Update mocking admin user with mock_admin_user()
thelovekesh Nov 24, 2022
e41fa2c
Fix duplicate WP user creation
thelovekesh Nov 24, 2022
2417d5b
Update current user capability to install_themes
thelovekesh Nov 24, 2022
8f51deb
Update AfterActivationSiteScanTest::test_get_amp_compatible_themes_ur…
thelovekesh Nov 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 85 additions & 17 deletions .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ jobs:
echo "Changed JS file count: $JS_FILE_COUNT"
echo "Changed GHA workflow file count: $GHA_WORKFLOW_COUNT"

echo "::set-output name=count::$FILE_COUNT"
echo "::set-output name=php-count::$PHP_FILE_COUNT"
echo "::set-output name=css-count::$CSS_FILE_COUNT"
echo "::set-output name=js-count::$JS_FILE_COUNT"
echo "::set-output name=gha-workflow-count::$GHA_WORKFLOW_COUNT"
echo "count=$FILE_COUNT" >> $GITHUB_OUTPUT
echo "php-count=$PHP_FILE_COUNT" >> $GITHUB_OUTPUT
echo "css-count=$CSS_FILE_COUNT" >> $GITHUB_OUTPUT
echo "js-count=$JS_FILE_COUNT" >> $GITHUB_OUTPUT
echo "gha-workflow-count=$GHA_WORKFLOW_COUNT" >> $GITHUB_OUTPUT
env:
# Ignore Paths:
# - .github/
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Configure Composer cache
uses: actions/cache@v3.0.11
Expand Down Expand Up @@ -222,7 +222,7 @@ jobs:

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Configure Composer cache
uses: actions/cache@v3.0.11
Expand Down Expand Up @@ -304,7 +304,7 @@ jobs:

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Configure Composer cache
uses: actions/cache@v3.0.11
Expand Down Expand Up @@ -457,7 +457,7 @@ jobs:
- name: Get Composer Cache Directory
if: needs.pre-run.outputs.changed-php-count > 0
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Configure Composer cache
if: needs.pre-run.outputs.changed-php-count > 0
Expand All @@ -475,7 +475,7 @@ jobs:
composer remove --dev phpdocumentor/reflection
composer install --prefer-dist --ignore-platform-reqs --no-progress --no-interaction

# See https://github.com/wp-cli/wp-cli/issues/5484
# See https://github.com/wp-cli/wp-cli/issues/5484
- name: Remove conflicting Requests library
if: needs.pre-run.outputs.changed-php-count > 0
run: composer remove --dev --ignore-platform-reqs --no-interaction --no-scripts roave/security-advisories wp-cli/export-command wp-cli/extension-command wp-cli/wp-cli wp-cli/wp-cli-tests
Expand Down Expand Up @@ -567,7 +567,76 @@ jobs:
flags: php,unit
fail_ci_if_error: true

#-----------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------

unit-test-multisite-php:
name: 'Unit Tests Multisite: PHP 7.4, WP Latest'
needs: pre-run
runs-on: ubuntu-latest
if: needs.pre-run.outputs.changed-php-count > 0
strategy:
matrix:
testsuite: ['default', 'external-http']

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3.5.1
with:
node-version-file: '.nvmrc'
cache: npm

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Configure Composer cache
uses: actions/cache@v3.0.11
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Node dependencies
run: npm ci
env:
CI: true

- name: Install Composer dependencies
run: |
# phpdocumentor/reflection has to be removed as it makes use of an outdated dependency.
composer remove --dev phpdocumentor/reflection
composer install --prefer-dist --ignore-platform-reqs --no-progress --no-interaction

# See https://github.com/wp-cli/wp-cli/issues/5484
- name: Remove conflicting Requests library
run: composer remove --dev --ignore-platform-reqs --no-interaction --no-scripts roave/security-advisories wp-cli/export-command wp-cli/extension-command wp-cli/wp-cli wp-cli/wp-cli-tests

- name: Update PHPUnit
if: needs.pre-run.outputs.changed-php-count > 0
run: |
# We are using PHP 7.4 and WP Latest.
echo "Installing latest version of PHPUnit"
composer update --ignore-platform-reqs --no-interaction --no-scripts yoast/phpunit-polyfills --with-dependencies

- name: Build plugin
run: npm run build:js

- name: Move amp-wp to amp
run: cp -r "$PWD" "/tmp/amp"

- name: Start wp-env
working-directory: /tmp/amp
run: npm run wp-env start

- name: Run multisite unit tests
working-directory: /tmp/amp
run: npm run test:php:multisite ${{ matrix.testsuite == 'external-http' && '-- --testsuite external-http' || '' }}

#-----------------------------------------------------------------------------------------------------------------------

feature-test-php:
name: "Feature test${{ matrix.coverage && ' (with coverage)' || '' }}: PHP ${{ matrix.php }}, WP ${{ matrix.wp }}"
Expand Down Expand Up @@ -641,7 +710,7 @@ jobs:

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Configure Composer cache
uses: actions/cache@v3.0.11
Expand Down Expand Up @@ -741,8 +810,7 @@ jobs:

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Configure Composer cache
uses: actions/cache@v3.0.11
Expand Down Expand Up @@ -774,11 +842,11 @@ jobs:

- name: Retrieve branch name
id: retrieve-branch-name
run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')"
run: echo "branch_name=$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_OUTPUT

- name: Retrieve git SHA-8 string
id: retrieve-git-sha-8
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
run: echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT

- name: Upload build as artifact
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -847,7 +915,7 @@ jobs:
- Download [development build](https://storage.googleapis.com/ampwp_github_artifacts/${{ github.ref }}/dev/amp.zip?${{ github.sha }})
- Download [production build](https://storage.googleapis.com/ampwp_github_artifacts/${{ github.ref }}/prod/amp.zip?${{ github.sha }})"
body="${body//$'\n'/'%0A'}"
echo "::set-output name=body::$body"
echo "body=$body" >> $GITHUB_OUTPUT

- name: Create comment on PR with links to plugin builds
if: ${{ steps.find-comment.outputs.comment-id == '' }}
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/gutenberg-packages-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
steps:
- name: Get latest release version
id: latest-release
run: echo "::set-output name=version::$(gh api -X GET repos/wordpress/gutenberg/releases/latest --jq '.name')"
run: echo "version=$(gh api -X GET repos/wordpress/gutenberg/releases/latest --jq '.name')" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -40,7 +40,7 @@ jobs:
if ! egrep -q '^[0-9][0-9]*(\.[0-9][0-9]*)*$' <<< "$LAST_VERSION"; then
LAST_VERSION='0.0.0'
fi
echo "::set-output name=version::$(echo "$LAST_VERSION")"
echo "version=$(echo "$LAST_VERSION")" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
QUERY: 'repo:ampproject/amp-wp is:pr author:app/github-actions is:merged in:title Update Gutenberg packages after'
Expand All @@ -50,7 +50,7 @@ jobs:
run: |
echo "Last version: $LAST_VER"
echo "Latest version: $LATEST_VER"
echo "::set-output name=outdated::$(php -r 'echo json_encode(version_compare($argv[1], $argv[2], ">"));' "$LATEST_VER" "$LAST_VER")"
echo "outdated=$(php -r 'echo json_encode(version_compare($argv[1], $argv[2], ">"));' "$LATEST_VER" "$LAST_VER")" >> $GITHUB_OUTPUT
env:
LAST_VER: ${{ steps.last-release.outputs.version }}
LATEST_VER: ${{ steps.latest-release.outputs.version }}
Expand All @@ -66,7 +66,7 @@ jobs:
id: latest-pr
run: |
PR_NUM=$(gh api -X GET search/issues -f q='${{ env.QUERY }}' -f sort='created' -f order='desc' --jq '.items.[0].number')
echo "::set-output name=num::$(echo $PR_NUM)"
echo "num=$(echo $PR_NUM)" >> $GITHUB_OUTPUT
echo "Latest PR number: ${PR_NUM}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -100,8 +100,8 @@ jobs:
- name: Determine branch name
id: branches
run: |
echo "::set-output name=base::$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=head::$(echo "update/gutenberg-v$VERSION-packages")"
echo "base=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "head=$(echo "update/gutenberg-v$VERSION-packages")" >> $GITHUB_OUTPUT
env:
VERSION: ${{ needs.check-gutenberg-release.outputs.latest-version }}

Expand All @@ -118,7 +118,7 @@ jobs:
- name: Check if remote branch exists
id: remote-branch
run: echo ::set-output name=exists::$([[ -z $(git ls-remote --heads origin "$HEAD_BRANCH" ) ]] && echo "0" || echo "1")
run: echo "exists=$([[ -z $(git ls-remote --heads origin "$HEAD_BRANCH" ) ]] && echo "0" || echo "1")" >> $GITHUB_OUTPUT
env:
HEAD_BRANCH: ${{ steps.branches.outputs.head }}

Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
run: |
# Get list of latest package versions.
PACKAGES=$(npm outdated --parseable | cut -d':' -f 4 | grep @wordpress | paste -s -d' ' || echo 0)
echo "::set-output name=list::$(echo "$PACKAGES")"
echo "list=$(echo "$PACKAGES")" >> $GITHUB_OUTPUT
- name: Update packages
if: steps.packages.outputs.list != 0
Expand Down
1 change: 1 addition & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"core": "WordPress/WordPress#master",
"phpVersion": "7.4",
"env": {
"development": {
"plugins": [
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"test:js:update-snapshots": "npm run test:js -- --updateSnapshot",
"test:js:watch": "npm run test:js -- --watch",
"test:php": "wp-env run phpunit 'env WP_PHPUNIT__TESTS_CONFIG=/wordpress-phpunit/wp-tests-config.php WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args'",
"test:php:multisite": "wp-env run phpunit 'env WP_MULTISITE=1 WP_PHPUNIT__TESTS_CONFIG=/wordpress-phpunit/wp-tests-config.php WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args'",
"test:php:xdebug": "wp-env run tests-wordpress 'env PHP_IDE_CONFIG=serverName=localhost WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit WP_PHPUNIT__TESTS_CONFIG=/wordpress-phpunit/wp-tests-config.php /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist $npm_config_args'",
"test:php:help": "npm run test:php --args='--help'",
"update-wordpress-packages": "npm i $(npm outdated --parseable | cut -d':' -f 4 | grep @wordpress)",
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/AfterActivationSiteScan.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected function get_amp_compatible_plugins_url() {
* @return string URL to AMP compatible themes directory.
*/
protected function get_amp_compatible_themes_url() {
if ( current_user_can( 'switch_themes' ) ) {
if ( current_user_can( 'install_themes' ) ) {
return admin_url( '/theme-install.php?browse=amp-compatible' );
}

Expand Down
7 changes: 4 additions & 3 deletions tests/php/src/Admin/AfterActivationSiteScanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use AmpProject\AmpWP\Services;
use AmpProject\AmpWP\Tests\DependencyInjectedTestCase;
use AmpProject\AmpWP\Tests\Helpers\PrivateAccess;
use AmpProject\AmpWP\Tests\Helpers\MockAdminUser;
use AMP_Validation_Manager;

/**
Expand All @@ -28,7 +29,7 @@
*/
class AfterActivationSiteScanTest extends DependencyInjectedTestCase {

use PrivateAccess;
use PrivateAccess, MockAdminUser;

/**
* Test instance.
Expand Down Expand Up @@ -276,7 +277,7 @@ function ( $caps, $cap ) {
* @covers ::get_amp_compatible_plugins_url
*/
public function test_get_amp_compatible_plugins_url() {
wp_set_current_user( self::factory()->user->create( [ 'role' => 'administrator' ] ) );
$this->mock_admin_user();
$this->assertStringContainsString( '/plugin-install.php?tab=amp-compatible', $this->call_private_method( $this->after_activation_site_scan, 'get_amp_compatible_plugins_url' ) );

wp_set_current_user( self::factory()->user->create( [ 'role' => 'author' ] ) );
Expand All @@ -287,7 +288,7 @@ public function test_get_amp_compatible_plugins_url() {
* @covers ::get_amp_compatible_themes_url
*/
public function test_get_amp_compatible_themes_url() {
wp_set_current_user( self::factory()->user->create( [ 'role' => 'administrator' ] ) );
$this->mock_admin_user();
$this->assertStringContainsString( '/theme-install.php?browse=amp-compatible', $this->call_private_method( $this->after_activation_site_scan, 'get_amp_compatible_themes_url' ) );

wp_set_current_user( self::factory()->user->create( [ 'role' => 'author' ] ) );
Expand Down
8 changes: 5 additions & 3 deletions tests/php/src/Admin/ReaderThemesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use AmpProject\AmpWP\Option;
use AmpProject\AmpWP\Tests\Helpers\LoadsCoreThemes;
use AmpProject\AmpWP\Tests\Helpers\ThemesApiRequestMocking;
use AmpProject\AmpWP\Tests\Helpers\MockAdminUser;
use AmpProject\AmpWP\Tests\TestCase;
use Closure;
use WP_Error;
Expand All @@ -28,7 +29,7 @@
*/
class ReaderThemesTest extends TestCase {

use ThemesApiRequestMocking, LoadsCoreThemes;
use ThemesApiRequestMocking, LoadsCoreThemes, MockAdminUser;

/**
* Test instance.
Expand Down Expand Up @@ -304,7 +305,8 @@ static function () {
}
);

wp_set_current_user( $this->factory()->user->create( [ 'role' => 'administrator' ] ) );
$this->mock_admin_user();

$expected = $get_expected();
$this->assertEquals( $expected, $this->reader_themes->get_theme_availability( $theme ) );
$this->assertEquals( $can_install, $this->reader_themes->can_install_theme( $theme ) );
Expand Down Expand Up @@ -344,7 +346,7 @@ static function () {
$this->assertFalse( $this->reader_themes->can_install_theme( $core_theme ) );
$this->assertFalse( $this->reader_themes->can_install_theme( $neve_theme ) );

wp_set_current_user( self::factory()->user->create( [ 'role' => 'administrator' ] ) );
$this->mock_admin_user();
$this->assertTrue( $this->reader_themes->can_install_theme( $core_theme ) );
$this->assertTrue( $this->reader_themes->can_install_theme( $neve_theme ) );

Expand Down
5 changes: 4 additions & 1 deletion tests/php/src/Admin/SiteHealthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use AmpProject\AmpWP\QueryVar;
use AmpProject\AmpWP\Tests\Helpers\HomeUrlLoopbackRequestMocking;
use AmpProject\AmpWP\Tests\Helpers\PrivateAccess;
use AmpProject\AmpWP\Tests\Helpers\MockAdminUser;
use AmpProject\AmpWP\Tests\TestCase;
use WP_REST_Server;
use WP_Error;
Expand All @@ -28,6 +29,7 @@ class SiteHealthTest extends TestCase {

use HomeUrlLoopbackRequestMocking;
use PrivateAccess;
use MockAdminUser;

/**
* Whether external object cache is being used.
Expand Down Expand Up @@ -139,7 +141,8 @@ public function test_register_async_test_endpoints() {
$this->assertFalse( call_user_func( $route['permission_callback'] ) );

// Prior to WordPress 5.2, the view_site_health_checks cap didn't exist because Site Health didn't exist.
wp_set_current_user( self::factory()->user->create( [ 'role' => 'administrator' ] ) );
$this->mock_admin_user();

if ( version_compare( get_bloginfo( 'version' ), '5.2', '>=' ) ) {
$this->assertTrue( call_user_func( $route['permission_callback'] ) );
} else {
Expand Down
5 changes: 4 additions & 1 deletion tests/php/src/Admin/SupportLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use AMP_Validation_Manager;
use AMP_Theme_Support;
use AMP_Validated_URL_Post_Type;
use AmpProject\AmpWP\Tests\Helpers\MockAdminUser;
use AmpProject\AmpWP\Tests\TestCase;

/**
Expand All @@ -23,6 +24,8 @@
*/
class SupportLinkTest extends TestCase {

use MockAdminUser;

/**
* Instance of SupportLink
*
Expand Down Expand Up @@ -65,7 +68,7 @@ public function test_is_needed() {
$this->assertFalse( SupportLink::is_needed() );

// Test 2: Test with admin user.
wp_set_current_user( self::factory()->user->create( [ 'role' => 'administrator' ] ) );
$this->mock_admin_user();

$this->assertTrue( SupportLink::is_needed() );
}
Expand Down
Loading