diff --git a/.gitignore b/.gitignore index cd2946ad..ca52fef2 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk + +# Composer +vendor/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5a991257..00000000 --- a/.travis.yml +++ /dev/null @@ -1,64 +0,0 @@ -# This uses newer and faster docker based build system -sudo: false - -language: php - -notifications: - on_success: never - on_failure: change - -services: - - mysql - -php: - - 7.4 - - 5.6 - -env: -# - WP_VERSION=bleeding WP_MULTISITE=0 -# - WP_VERSION=bleeding-maintenance WP_MULTISITE=0 - - WP_VERSION=latest WP_MULTISITE=0 - - WP_VERSION=latest WP_MULTISITE=1 - -matrix: - allow_failures: - - php: nightly # PHP 8.x - - env: WP_VERSION=bleeding WP_MULTISITE=0 -# - env: WP_VERSION=bleeding-maintenance WP_MULTISITE=0 - - include: - - php: nightly - env: WP_VERSION=bleeding WP_MULTISITE=0 - - php: nightly - env: WP_VERSION=latest WP_MULTISITE=0 - - php: 7.3 - env: WP_VERSION=latest WP_MULTISITE=0 - - php: 7.0 - env: WP_VERSION=latest WP_MULTISITE=0 - - php: 5.6 - env: WP_VERSION=5.3 WP_MULTISITE=0 - -## Cache composer bits -cache: - apt: true - directories: - - vendor - - $HOME/.composer/cache - -before_script: - - if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != 'nightly' ]]; then - phpenv config-rm xdebug.ini; - fi - -# Install composer packages before trying to activate themes or plugins - - if [[ $TRAVIS_PHP_VERSION != 5.2 ]]; then - composer self-update; - composer install --no-interaction --prefer-source; - fi - -# - git clone https://github.com/Seravo/wordpress-test-template wp-tests - - bash bin/install-wp-tests.sh test root '' localhost $WP_VERSION - -script: - - vendor/bin/phpunit -# - cd tests/spec && bundle exec rspec test.rb diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh deleted file mode 100644 index a074f481..00000000 --- a/bin/install-wp-tests.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/env bash - -if [ $# -lt 3 ]; then - echo "usage: $0 [db-host] [wp-version] [force download] [skip-database-creation]" - exit 1 -fi - -DB_NAME=$1 -DB_USER=$2 -DB_PASS=$3 -DB_HOST=${4-localhost} -WP_VERSION=${5-latest} -FORCE=${6-false} -SKIP_DB_CREATE=${7-false} - -WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} -WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} - -# Placeholder for download agent -# @todo replace back to wget everywhere in this file -download() { - - if [ `which curl` ]; then - curl -s "$1" > "$2"; - elif [ `which wget` ]; then - wget -nv -O "$2" "$1" - fi - -} - -# Detect version tag -# Format: N.N.N -if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then - WP_TESTS_TAG="tags/$WP_VERSION" -elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then - WP_TESTS_TAG="trunk" -else - # http serves a single offer, whereas https serves multiple. we only want one - download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json - grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json - LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') - - if [[ -z "$LATEST_VERSION" ]]; then - echo "Latest WordPress version could not be found" - exit 1 - fi - - WP_TESTS_TAG="tags/$LATEST_VERSION" -fi - -if [[ $WP_TESTS_TAG == *"beta"* ]] -then - WP_TESTS_TAG="trunk" -fi - -set -ex - -install_wp() { - - echo "Installing WordPress for Unit Tests" - - if [[ $FORCE == 'true' || -z TRAVIS_JOB_ID ]]; then - echo "Removing existing core WordPress directory" - - rm -Rf $WP_CORE_DIR - fi - - if [ -d $WP_CORE_DIR ]; then - return; - fi - - echo "Downloading WordPress" - - mkdir -p $WP_CORE_DIR - - if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then - mkdir -p /tmp/wordpress-nightly - download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip - unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/ - mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR - else - if [ $WP_VERSION == 'latest' ]; then - local ARCHIVE_NAME='latest' - else - local ARCHIVE_NAME="wordpress-$WP_VERSION" - fi - - download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz - tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR - fi - - download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php - - echo "WordPress installed" - -} - -install_test_suite() { - - echo "Installing Tests Suite for Unit Tests" - - if [[ $FORCE == 'true' || -z TRAVIS_JOB_ID ]]; then - echo "Removing existing Tests Suite directory" - - rm -Rf $WP_TESTS_DIR - fi - - # portable in-place argument for both GNU sed and Mac OS X sed - if [[ $(uname -s) == 'Darwin' ]]; then - local ioption='-i .bak' - else - local ioption='-i' - fi - - # set up testing suite if it doesn't yet exist - if [ ! -d $WP_TESTS_DIR ]; then - echo "Downloading Tests Suite" - - # set up testing suite - mkdir -p $WP_TESTS_DIR - svn export --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes $WP_TESTS_DIR/includes - svn export --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data $WP_TESTS_DIR/data - fi - - cd $WP_TESTS_DIR - - if [ ! -f wp-tests-config.php ]; then - download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php - # remove all forward slashes in the end - WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") - sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php - fi - - echo "Tests Suite installed" - -} - -install_db() { - - if [ ${SKIP_DB_CREATE} = "true" ]; then - return 0 - fi - - echo "Setting up Database for Unit Tests" - - # parse DB_HOST for port or socket references - local PARTS=(${DB_HOST//\:/ }) - local DB_HOSTNAME=${PARTS[0]}; - local DB_SOCK_OR_PORT=${PARTS[1]}; - local EXTRA="" - - if ! [ -z $DB_HOSTNAME ] ; then - if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then - EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" - elif ! [ -z $DB_SOCK_OR_PORT ] ; then - EXTRA=" --socket=$DB_SOCK_OR_PORT" - elif ! [ -z $DB_HOSTNAME ] ; then - EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" - fi - fi - - if [[ $FORCE == 'true' || -z TRAVIS_JOB_ID ]]; then - echo "Removing existing Database" - - # drop database - mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA -e "DROP DATABASE IF EXISTS $DB_NAME" - fi - - echo "Creating Database" - - # create database - mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA - - echo "Database set up" - -} - -install_wp -install_test_suite -install_db diff --git a/composer.json b/composer.json index 80609053..f0d944aa 100644 --- a/composer.json +++ b/composer.json @@ -40,11 +40,10 @@ }, "require-dev": { "phpmd/phpmd": "@stable", - "phpunit/phpunit": "5.*", - "mockery/mockery": "1.3.*", + "phpunit/phpunit": "^8", "squizlabs/php_codesniffer": "2.*", - "phpcompatibility/php-compatibility": "9.*", - "yoast/phpunit-polyfills": "2.0" + "phpcompatibility/phpcompatibility-wp": "*", + "yoast/phpunit-polyfills": "3.0" }, "extra": { "installer-name": "view-admin-as" diff --git a/includes/class-compat.php b/includes/class-compat.php index f2cd6242..14602d00 100644 --- a/includes/class-compat.php +++ b/includes/class-compat.php @@ -468,7 +468,7 @@ public function filter_ure_capabilities_groups_tree( $groups ) { $groups['view_admin_as'] = array( 'caption' => esc_html__( 'View Admin As', VIEW_ADMIN_AS_DOMAIN ), 'parent' => 'custom', - 'level' => 3, + 'level' => 2, ); return $groups; } diff --git a/includes/class-controller.php b/includes/class-controller.php index 8fb6ef5d..11311436 100644 --- a/includes/class-controller.php +++ b/includes/class-controller.php @@ -108,19 +108,23 @@ public function init() { * * @since 0.1.0 * @since 1.2.0 Only check for key + * @since 1.8.10 Reset view in store * @example http://www.your.domain/wp-admin/?reset-view */ if ( VAA_API::is_request( 'reset-view', 'get' ) ) { $this->reset_view(); + $this->store->set_view( array() ); } /** * Clear all user views. * * @since 1.3.4 + * @since 1.8.10 Reset view in store * @example http://www.your.domain/wp-admin/?reset-all-views */ if ( VAA_API::is_request( 'reset-all-views', 'get' ) ) { $this->reset_all_views(); + $this->store->set_view( array() ); } } diff --git a/includes/class-type.php b/includes/class-type.php index 47a09eda..73b58be8 100644 --- a/includes/class-type.php +++ b/includes/class-type.php @@ -142,7 +142,13 @@ protected function __construct( $vaa ) { } if ( $this->is_enabled() ) { - $this->add_action( 'vaa_view_admin_as_pre_init', array( $this, 'init' ) ); + $this->add_action( 'vaa_view_admin_as_pre_init', array( $this, 'setup' ) ); + + if ( did_action( 'init' ) ) { + $this->init(); + } else { + $this->add_action( 'init', array( $this, 'init' ) ); + } } } @@ -191,11 +197,12 @@ public function set_enable( $bool = false, $update_db = true ) { /** * Setup module and hooks. * - * @since 1.8.0 + * @since 1.8.0 Renamed from init() + * @since 1.8.10 * @access protected - * @return bool Successful init? + * @return bool Successful setup? */ - public function init() { + public function setup() { $this->store_data(); @@ -207,6 +214,17 @@ public function init() { return false; } + /** + * Init module and hooks. + * + * @since 1.8.10 + * @access protected + * @return bool Successful init? + */ + public function init() { + return true; + } + /** * Setup hooks. * diff --git a/includes/class-update.php b/includes/class-update.php index 56a72bc0..2d97a681 100644 --- a/includes/class-update.php +++ b/includes/class-update.php @@ -61,7 +61,7 @@ protected function __construct( $vaa ) { * @return void */ public function maybe_db_update() { - $db_version = strtolower( $this->store->get_optionData( 'db_version' ) ); + $db_version = strtolower( (string) $this->store->get_optionData( 'db_version' ) ); if ( ! $db_version ) { self::$fresh_install = true; } @@ -83,7 +83,7 @@ private function db_update() { 'db_version' => $this->store->get_dbVersion(), ); - $current_db_version = strtolower( $this->store->get_optionData( 'db_version' ) ); + $current_db_version = strtolower( (string) $this->store->get_optionData( 'db_version' ) ); // No need to run update script if it's a clean installation. if ( $current_db_version ) { diff --git a/modules/class-caps.php b/modules/class-caps.php index 96f09bd5..8e37d4c2 100644 --- a/modules/class-caps.php +++ b/modules/class-caps.php @@ -67,9 +67,15 @@ protected function __construct( $vaa ) { 'update_view' => 10, 'do_view' => 8, ); + } + /** + * @inheritDoc + */ + public function init() { $this->label = __( 'Capabilities', VIEW_ADMIN_AS_DOMAIN ); $this->label_singular = __( 'Capability', VIEW_ADMIN_AS_DOMAIN ); + return parent::init(); } /** diff --git a/modules/class-groups.php b/modules/class-groups.php index 9548cb7e..0a376106 100644 --- a/modules/class-groups.php +++ b/modules/class-groups.php @@ -87,10 +87,6 @@ protected function __construct( $vaa ) { $this->priorities['toolbar'] = 40; - $this->label = $this->translate_remote( 'Groups' ); - $this->label_singular = $this->translate_remote( 'Group' ); - $this->description = __( 'Plugin' ) . ': ' . $this->label; - // Add groups capabilities. $this->capabilities[] = $this->cap; if ( defined( 'GROUPS_ACCESS_GROUPS' ) ) { @@ -112,9 +108,9 @@ protected function __construct( $vaa ) { * @since 1.7.4 * @access private */ - public function init() { + public function setup() { - if ( parent::init() ) { + if ( parent::setup() ) { if ( defined( 'GROUPS_PLUGIN_URL' ) ) { $this->icon = GROUPS_PLUGIN_URL . '/images/groups.png'; @@ -125,6 +121,16 @@ public function init() { } } + /** + * @inheritDoc + */ + public function init() { + $this->label = $this->translate_remote( 'Groups' ); + $this->label_singular = $this->translate_remote( 'Group' ); + $this->description = __( 'Plugin' ) . ': ' . $this->label; + return parent::init(); + } + /** * Initialize the Groups module. * @since 1.7.2 diff --git a/modules/class-languages.php b/modules/class-languages.php index c88c0eca..9406f0be 100644 --- a/modules/class-languages.php +++ b/modules/class-languages.php @@ -74,9 +74,15 @@ protected function __construct( $vaa ) { 'update_view' => 10, 'do_view' => 10, ); + } + /** + * @inheritDoc + */ + public function init() { $this->label = __( 'Languages', VIEW_ADMIN_AS_DOMAIN ); $this->label_singular = __( 'Language', VIEW_ADMIN_AS_DOMAIN ); + return parent::init(); } /** diff --git a/modules/class-restrict-user-access.php b/modules/class-restrict-user-access.php index 2407e960..b39722d1 100644 --- a/modules/class-restrict-user-access.php +++ b/modules/class-restrict-user-access.php @@ -133,10 +133,6 @@ protected function __construct( $vaa ) { $this->priorities['toolbar'] = 40; - $this->label = 'Access Levels'; - $this->label_singular = 'Access Level'; - $this->description = __( 'Plugin' ) . ': ' . $this->translate_remote( 'Restrict User Access' ); - $this->add_action( 'init', array( $this, 'set_labels' ), 99999 ); } @@ -160,9 +156,9 @@ public function set_labels() { * @since 1.7.4 * @access private */ - public function init() { + public function setup() { - if ( parent::init() ) { + if ( parent::setup() ) { $this->add_action( 'vaa_admin_bar_roles_after', array( $this, 'admin_bar_roles_after' ), 10, 2 ); } else { // Add this anyway to reset user level caps. @@ -170,6 +166,13 @@ public function init() { } } + public function init() { + $this->label = 'Access Levels'; + $this->label_singular = 'Access Level'; + $this->description = __( 'Plugin' ) . ': ' . $this->translate_remote( 'Restrict User Access' ); + return parent::init(); // TODO: Change the autogenerated stub + } + /** * Initialize the RUA module. * diff --git a/modules/class-roles.php b/modules/class-roles.php index 9fff08ba..bd6f8a5d 100644 --- a/modules/class-roles.php +++ b/modules/class-roles.php @@ -77,9 +77,15 @@ protected function __construct( $vaa ) { 'update_view' => 10, 'do_view' => 5, ); + } + /** + * @inheritDoc + */ + public function init() { $this->label = __( 'Roles', VIEW_ADMIN_AS_DOMAIN ); $this->label_singular = __( 'Role', VIEW_ADMIN_AS_DOMAIN ); + return parent::init(); } /** diff --git a/modules/class-users.php b/modules/class-users.php index 0abf4073..11096eb4 100644 --- a/modules/class-users.php +++ b/modules/class-users.php @@ -92,9 +92,6 @@ protected function __construct( $vaa ) { 'do_view' => 2, ); - $this->label = __( 'Users', VIEW_ADMIN_AS_DOMAIN ); - $this->label_singular = __( 'User', VIEW_ADMIN_AS_DOMAIN ); - $this->init_hooks(); if ( $this->is_enabled() ) { @@ -123,6 +120,15 @@ protected function __construct( $vaa ) { } } + /** + * @inheritDoc + */ + public function init() { + $this->label = __( 'Users', VIEW_ADMIN_AS_DOMAIN ); + $this->label_singular = __( 'User', VIEW_ADMIN_AS_DOMAIN ); + return parent::init(); + } + /** * Apply the user view. * diff --git a/readme.txt b/readme.txt index 1c1432fa..b193920c 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: keraweb Donate link: https://www.keraweb.nl/donate.php?for=view-admin-as Tags: admin, view, roles, users, switch, user switching, role switching, capabilities, caps, screen settings, defaults, visitor Requires at least: 4.1 -Tested up to: 6.5 +Tested up to: 6.7 Requires PHP: 5.2.4 -Stable tag: 1.8.9 +Stable tag: 1.8.10 View the WordPress admin as a different role or visitor, switch between users, temporarily change your capabilities, set screen settings for roles. @@ -209,6 +209,15 @@ Yes, see *Install as a must-use plugin* on the *Installation* tab. == Changelog == += 1.8.10 = + +* **Compatibility:** Move label initialization to fix `_load_textdomain_just_in_time` notice since WP 6.7. +* **Fix:** Clear view in current session when resetting manually. +* **Fix:** URE Integration: Fix the level at which the View Admin As group appears. [#135](https://github.com/JoryHogeveen/view-admin-as/pull/135) (credits @pbiron) +* **Tests:** Fix unit tests. + +Detailed info: [PR on GitHub](https://github.com/JoryHogeveen/view-admin-as/pull/136) + = 1.8.9 = * **Fix:** Event bubbling for select elements [#130](https://github.com/JoryHogeveen/view-admin-as/issues/130) diff --git a/tests/test-api.php b/tests/test-api.php index 760c50f7..426cee0e 100644 --- a/tests/test-api.php +++ b/tests/test-api.php @@ -127,7 +127,7 @@ function test_get_array_data() { // The above didn't cause an error :( $this->assertTrue( false ); - } catch ( Exception $e ) { + } catch ( Throwable $e ) { // Above caused an error! $this->assertTrue( true ); } diff --git a/tests/test-controller.php b/tests/test-controller.php index 2a8b99ae..297622fd 100644 --- a/tests/test-controller.php +++ b/tests/test-controller.php @@ -16,7 +16,7 @@ public static function get_instance() { return view_admin_as()->controller(); } - public function setUp() { + protected function setUp(): void { parent::setUp(); add_action( 'vaa_view_admin_as_update_view', array( 'VAA_Controller_UnitTest', 'action_callback' ) ); add_action( 'vaa_view_admin_as_reset_view', array( 'VAA_Controller_UnitTest', 'action_callback' ) ); diff --git a/tests/test-module-role-defaults.php b/tests/test-module-role-defaults.php index 886fb44e..cbe4adbf 100644 --- a/tests/test-module-role-defaults.php +++ b/tests/test-module-role-defaults.php @@ -140,14 +140,14 @@ function test_import_export() { // @todo Patch if data only is possible. $result = $class->import_role_defaults( $editor_import ); - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); $import = array( 'editor' => $editor_import, ); $result = $class->import_role_defaults( $import ); - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); $this->assertEquals( $import, $class->get_role_defaults() ); /** @@ -157,7 +157,7 @@ function test_import_export() { $result = $class->import_role_defaults( $import ); // Should return error list array because of the invalid meta key. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); // Make sure the key doesn't exists in the role defaults. unset( $import['editor']['invalid_key'] ); @@ -170,7 +170,7 @@ function test_import_export() { $overwrite['editor']['admin_color'] = 'dark'; $result = $class->import_role_defaults( $overwrite, 'merge' ); - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); // Check export import overwrite. $this->assertEquals( $overwrite, $class->export_role_defaults() ); @@ -180,7 +180,7 @@ function test_import_export() { * Import append. */ $result = $class->import_role_defaults( $import, 'append' ); - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); // Check export import append. Editor admin color should still be `dark`. $this->assertEquals( $overwrite, $class->export_role_defaults() ); @@ -192,7 +192,7 @@ function test_import_export() { ), ); $result = $class->import_role_defaults( $import_admin ); - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); /** * Check export for a single role. @@ -225,13 +225,13 @@ function test_get_copy() { * Invalid, non existing role. */ $result = $class->copy_role_defaults( 'editor', 'non_existing_role' ); - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); /** * Copy defaults. */ $result = $class->copy_role_defaults( 'editor', 'author' ); - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); // Check if copy was actually successful. Also checks getting role defaults with role parameter. $check = array( @@ -260,7 +260,7 @@ function test_clear() { */ $result = $class->clear_role_defaults( 'non_existing_role' ); // @todo Currently still returns true, maybe return false if role doesn't exists? - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); // Should still be the same. $this->assertEquals( $defaults, $class->get_role_defaults() ); @@ -268,7 +268,7 @@ function test_clear() { * Clear defaults, single role. */ $result = $class->clear_role_defaults( 'author' ); - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); $new_defaults = $defaults; unset( $new_defaults['author'] ); @@ -279,7 +279,7 @@ function test_clear() { * Clear all. */ $result = $class->clear_role_defaults( '__all__' ); - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); $this->assertEquals( array(), $class->get_role_defaults() ); diff --git a/tests/test-module-role-manager.php b/tests/test-module-role-manager.php index 48b73439..ab3b08db 100644 --- a/tests/test-module-role-manager.php +++ b/tests/test-module-role-manager.php @@ -102,7 +102,7 @@ function test_import() { */ $result = $class->import_roles( 'test' ); // We expect an error string. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); $caps = array( 'read' => array( 'yay' ), @@ -110,7 +110,7 @@ function test_import() { ); $result = $class->import_roles( $caps ); // We expect an error array. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); /** * Correct. @@ -123,7 +123,7 @@ function test_import() { $result = $class->import_roles( array( 'data' => array( $role => $caps ), ) ); - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); $test_import = get_role( $role ); @@ -144,14 +144,14 @@ function test_clone() { */ $result = $class->clone_role( 'non_existing_role', $role ); // We expect an error string. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); /** * Correct. */ $result = $class->clone_role( 'editor', $role ); // We expect an error string. - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); $editor = get_role( 'editor' ); $test_clone = get_role( $role ); @@ -173,24 +173,24 @@ function test_rename() { */ $result = $class->rename_role( 'non_existing_role', $rename ); // We expect an error string. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); /** * Correct. */ $result = $class->rename_role( 'editor', $rename ); // We expect an error string. - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); $editor = get_role( 'editor' ); // The editor name should be the new name. - $this->assertEquals( $editor->name, $rename ); + $this->assertSame( $editor->name, $rename ); // Revert change. $class->rename_role( 'editor', 'Editor' ); $editor = get_role( 'editor' ); // Verify that the role is renamed. - $this->assertEquals( $editor->name, 'Editor' ); + $this->assertSame( $editor->name, 'Editor' ); } @@ -208,18 +208,18 @@ function test_delete() { */ $result = $class->delete_role( 'non_existing_role' ); // We expect an error string. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); /** * Protected roles. */ $result = $class->delete_role( 'administrator' ); // We expect an error string. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); $result = $class->delete_role( get_option( 'default_role' ) ); // We expect an error string. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); /** * Correct. @@ -258,11 +258,11 @@ function test_migrate_users() { */ $result = $class->delete_role( 'editor', 'non_existing_role' ); // We expect an error string. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); $result = $class->delete_role( 'editor', 'editor' ); // We expect an error string. - $this->assertNotEquals( true, $result ); + $this->assertNotSame( true, $result ); /** * Correct. @@ -271,7 +271,7 @@ function test_migrate_users() { $result = $class->delete_role( 'editor', 'test_migrate' ); // Should be ok! - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); /** * Revert @@ -284,7 +284,7 @@ function test_migrate_users() { 'new_role' => 'editor', ) ); // Should be ok! - $this->assertEquals( true, $result ); + $this->assertSame( true, $result ); // Load all roles again after removal. VAA_UnitTest_Factory::vaa_reinit(); diff --git a/tests/unittestcase.php b/tests/unittestcase.php index 8501d8f1..5d4aa45a 100644 --- a/tests/unittestcase.php +++ b/tests/unittestcase.php @@ -8,7 +8,7 @@ class VAA_UnitTestCase extends WP_UnitTestCase { - public function setUp() { + protected function setUp(): void { parent::setUp(); wp_set_current_user( 1 ); VAA_UnitTest_Factory::vaa_reinit(); diff --git a/view-admin-as.php b/view-admin-as.php index 23a86d44..121367d7 100644 --- a/view-admin-as.php +++ b/view-admin-as.php @@ -3,7 +3,7 @@ * @author Jory Hogeveen * @package View_Admin_As * @since 0.1.0 - * @version 1.8.9 + * @version 1.8.10 * @licence GPL-2.0+ * @link https://github.com/JoryHogeveen/view-admin-as * @@ -11,7 +11,7 @@ * Plugin Name: View Admin As * Plugin URI: https://wordpress.org/plugins/view-admin-as/ * Description: View the WordPress admin as a different role or visitor, switch between users, temporarily change your capabilities, set default screen settings for roles. - * Version: 1.8.9 + * Version: 1.8.10 * Author: Jory Hogeveen * Author URI: https://www.keraweb.nl * Text Domain: view-admin-as @@ -44,7 +44,7 @@ if ( ! class_exists( 'VAA_View_Admin_As' ) && ! function_exists( 'view_admin_as' ) ) { - define( 'VIEW_ADMIN_AS_VERSION', '1.8.9' ); + define( 'VIEW_ADMIN_AS_VERSION', '1.8.10' ); define( 'VIEW_ADMIN_AS_DB_VERSION', '1.8' ); define( 'VIEW_ADMIN_AS_DOMAIN', 'view-admin-as' ); define( 'VIEW_ADMIN_AS_FILE', __FILE__ );