Download the PHP package jdgrimes/wp-plugin-uninstall-tester without Composer

On this page you can find all versions of the php package jdgrimes/wp-plugin-uninstall-tester. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-plugin-uninstall-tester

WP Plugin Uninstall Tester

A testcase class for testing plugin install and uninstall, with related tools.

Notice

This project is no longer maintained. It has been merged into the WP Plugin PHPUnit Bootstrap. It is recommended that you use that instead.

Background

The purpose of this testcase is to allow you to make plugin uninstall testing as realistic as possible. WordPress uninstalls plugins when they aren't active, and these tools allow you simulate that. The installation is performed remotely, so the plugin is not loaded when the tests are being run.

I created these tools after finding that there was a fatal error in one of my plugin's uninstall scripts. Not that I didn't have unit tests for uninstallation. I did. But the uninstall tests were being run with the plugin already loaded. So I never realized that I was calling one of the plugin's functions that wouldn't normally be available. That's when I decided to create these testing tools, so my uninstall tests would fail if I wasn't including all required dependencies in my plugin's uninstall script.

In addition to providing a realistic uninstall testing environment, it also provides some assertions to help you make sure that your plugin entirely cleaned up the database.

Installation

Composer

Set Up

Once you have the testing tools installed, you need to make a few changes to your bootstrap file for PHPUnit. We're going to assume that you have a bootstrap file similar to the one in this tutorial.

First, you need to include the /includes/functions.php file, so you can use running_wp_plugin_uninstall_tests() to check if the uninstall tests are being run. You need to be sure that you only load your plugin's files if the uninstall tests aren't being run.

Secondly, you need to include the bootstrap.php file:

Thirdly, you need to exclude the uninstall group from the tests in your PHPUnit XML config file:

That will exclude the uninstall tests from running by default. To run them, you'll need to do phpunit --group=uninstall.

Finally, you need to make sure that you've copied or symlinked your plugin into the plugins folder of the test site (if you aren't developing it there already):

Usage

Now, it's finally time to create a testcase. To do this, extend the WP_Plugin_Uninstall_UnitTestCase class.

Save your testcase and you are all set!

Plugin Usage Simulation

The above example is a great first step in testing that your plugin is uninstalling itself completely. However, you can probably do better. The above testcase is only testing uninstallation from a fresh, clean install of your plugin. But what about after the user has actually used your plugin for a while? It will probably have added some more options to the database somewhere along the way. To have more robust and complete uninstall tests, it is needful to simulate plugin usage.

The testcase has provided for this. To use this feature, write up a script that will simulate your plugin being used. Call your various functions that add data to the database, for example. Save your code in a file.

Now all you need to do for the testcase to run the simulation, is specify the path of the file you just created in the $simulation_file class property (same as we did with the main plugin file and the $plugin_file property above).

The plugin usage simulation script will now be run remotely before the plugin is uninstalled. You can also run it before this if needed, by calling $this->simulate_usage().

License

This library is provided under the MIT license.


All versions of wp-plugin-uninstall-tester with dependencies

PHP Build Version
Package Version
Requires php Version >=5.2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jdgrimes/wp-plugin-uninstall-tester contains the following files

Loading the files please wait ....