Download the PHP package automattic/wordbless without Composer

On this page you can find all versions of the php package automattic/wordbless. 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 wordbless

WorDBless

CI

WorDBless allows you to use WordPress core functions in your PHPUnit tests without having to set up a database and the whole WordPress environment

Usage

Require WorDBless

Make sure to copy db.php

Add this script to your composer.json:

Alternatively, you can manually copy src/dbless-wpdb.php to the wordpress folder created in your project under wp-content/db.php.

Initialize it in your bootstrap file

In your PHP Unit bootstrap file add:

That's it! You can now use WordPress core functions in your tests!

Writing tests

Extend the BaseTestCase in order to have all the setup and teardown in place.

Note WorDBless uses @before and @after annotations rather than overriding PHPUnit's setUp and tearDown methods.

If you choose not to extend this base class, no problem. Just remember that WorDBless won't be set up or torn down for you. Check BaseTestCase::set_up_wordbless() and BaseTestCase::teardown_wordbless() to see how to do it for yourself.

What will work and what will not work?

Disclaimer: This is still experimental, so all testing is very welcome.

Basically any WordPress core function will work. Things like wp_parse_args, add_query_arg, etc.

Hooks and filters will work.

Most of the things that uses the database WILL NOT work, unless you believe in magic.

What magic WorDBless adds?

Options

Manipulating options will work. get_option, update_option, add_option and delete_option should work fine!

Posts and Post meta

Manipulating (creating, updating, deleting) posts and attachments will work. Fetching a single post will also work. Here is a non-exaustive list of functions supported:

Note: Fetching posts using WP_Query will not work (yet)! To fetch a post, use get_post( $id ).

Users and capabilities

You can create, edit and delete users.

Here is a non-exaustive list of functions supported:

Posts can be assigned to users and proper capabilities will be correctly checked. When deleting a user, reassigning posts to other user will also work.

Note: Fetching users using WP_Users_Query will not work! To fetch a user, use get_userdata(), get_user_by or WP_User class.

Populating default options

By default, only siteurl and home options are populated with http://example.org.

If you want, you can add more options to be loaded by default.

Just declare a dbless_default_options() function in your bootstrap and make it return an array where the keys are option names and values, options values.

Examples

Here's a simple example, using only few WordPress functions:

Jetpack Admin UI package

And here a more complex example, using WorDBless to test REST endpoints, create users and play with hooks:

Jetpack Backup package

Running our CI locally

First install phive globally on your computer.

Then issue the following single command.


All versions of wordbless with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.20
roots/wordpress Version ^6.0.2
yoast/phpunit-polyfills Version ^1.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 automattic/wordbless contains the following files

Loading the files please wait ....