Download the PHP package makeweb/wordpress-test-environment without Composer

On this page you can find all versions of the php package makeweb/wordpress-test-environment. 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 wordpress-test-environment

Wordpress Test Environment

Easily pull Wordpress in to your plugin, library or package as a composer development dependency and test your code in an actual wordpress environment.

This package aims to support developers who wish to test code which depends on Wordpress in two key ways:

1) Boot wordpress to allow usage of wordpress database and global functions

2) Simulate actual HTTP requests to the wordpress application

Installation

From command line:

composer require --dev makeweb/wordpress-test-environment

Basic Usage

1) Once installed, Create a new database in your local MySQL installation.

2) Create a .env file in the base directory of the codebase you are testing and add the following to it (updating the credentials to match your newly created database and local environment):

3) Initialise Wordpress in your parent test case class

Pass the relative path to the directory which contains your .env file into loadEnvFrom()

4) Usage in your tests

Boot only

If you simply wish to boot wordpress to allow access to the database and Wordpress global functions. Add the following lines to the start of your test.

In your test file

In your main plugin file or source code

Here we are just calling a native Wordpress function get_site_url(). If everything is set up correctly the test above will pass with the code below because get_site_url() has been defined by wordpress.

Note: Make sure you are including the plugin file in your test bootstrap file manually or with an autoloader like composer

Test HTTP requests to your wordpress application

Sometimes your theme, plugin or library might actually handle HTTP requests (for example, if you are creating an API), or perhaps you just want to test the way your code affects the actual html output of the application. The Wordpress class exposes a get method which simulates an actual HTTP GET request to the given url. Wordpress, and your dependent code will be booted and executed as it would be in production. We don't need to call $this->wordpress->boot() when using the HTTP methods because it is done for us automatically.

In your test file

In your plugin file or source code


All versions of wordpress-test-environment with dependencies

PHP Build Version
Package Version
Requires wordpress/wordpress Version ^4.9.5
vlucas/phpdotenv Version ^2.4
illuminate/support Version ^5.6
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 makeweb/wordpress-test-environment contains the following files

Loading the files please wait ....