Download the PHP package ideasonpurpose/wp-test-stubs without Composer

On this page you can find all versions of the php package ideasonpurpose/wp-test-stubs. 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-test-stubs

wp-test-stubs

WP Test Stubs

Version 0.2.0

Packagist styled with prettier

A simple collection of stubs and doubles for testing WordPress code.

Unlike Brain Monkey or WP_Mock, this is a very dumb library.

Most functions are just empty stubs or return a matching global variable.

add_action and add_filter

The add_action, remove_action, add_filter and remove_filter functions record calls in global $actions or $filters arrays. Each call pushes an associative array onto the stack containing the hook, action, priority and args. Check those global arrays to see whether the action/filter was called correctly.

Any functions which need testing should be public and capable of being tested independently.

all_added_actions and all_added_filters helper functions

These two helper functions return a simplified view of the global $actions and $filters arrays with each added hook represented as two-item, hook/action array: ['hook_name', 'method_name']. The two parallel functions, all_removed_actions and all_removed_filters can be used with PHPUnit like this:

For short-arrow and anonymous functions (Closures), test for their returned values. For example, fn() => 5 can be validated with assertContains(['hook_name', 5].

is_{$something} functions

All of these functions are mocked from the same pattern: Each will return the value of a global with the same name as the function. Since these functions are often used for control flow, being able to easily toggle their values makes it simple to test alternate pathways through System Under Test code without having to refactor.

To toggle any is_ function, set a value like this:

Local Development

To have Composer check out a live clone of this repo instead of downloading an archive from Packagist, add a repositories key to the root of your project's composer.json file:

 

Brought to you by IOP

IOP Logo This project is actively developed and used in production at Ideas On Purpose.


All versions of wp-test-stubs with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.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 ideasonpurpose/wp-test-stubs contains the following files

Loading the files please wait ....