Download the PHP package lifterlms/lifterlms-tests without Composer

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

LifterLMS Tests

LifterLMS Tests is a project to help bootstrap automated testing in LifterLMS projects.

Installation

Commands

Environment

The llms-env command provides a simple set of tools helpful in managing a set of Docker containers for use in development and testing of a LifterLMS plugin.

For customization, run llms-env config to create the recommended docker-compose.yml and .llmsenv files in the project root.

The docker-compose.yml will automatically mount the root directory into the wp-content/plugin directory.

The .llmsenv file allows customization of the WordPress username, localhost port, and more. This file is optional and the defaults will be used if any variables are excluded.

After setting up the configuration files run llms-env up to create the containers, install, and configure WordPress.

If any additional plugins are required or any other WordPress configurations are required, try creating a composer script that runs the required commands via wp-cli on the main PHP service container. For example, add a script in your composer.json:

This can be run to activate the LifterLMS core.

The llms-env provides many commands for composing and managing the Docker containers. Run llms-env --help for a full list of available commands as well as information on their usage.

Predefined scripts

The following scripts can be added to your composer.json file for easy access to thes scripts & to ensure configurations are automatically set during package installation and updates.

Utilities

Utility methods are located in the LLMS_Unit_Test_Util class.

Retrieve a private/protected class method:

Call a private/protected class method for testing:

Functions

Mock the return of llms_current_time() by using llms_tests_mock_current_time( $timestamp_or_date )

Reset the current time with llms_tests_reset_current_time()

Test Case Methods

Test cases which extend the LLMS_Unit_Test_Case class may access utility functiosn built into the test case class.

Assertions

Test cases which extend the LLMS_Unit_Test_Case class may access utility functiosn built into the test case class.

Assets

Assert that assets (scripts or styles) are registered or enqueued (or inversely not registered or not enqueued) with WordPress dependency managements classes.

$type is either "script" or "style" and $handle is the asset handle used to register/enqueue the script.

Output Buffering
WP_Error
Mock $_GET, $_POST, and $_REQUEST data

Add mock $_GET data via $this->mockGetRequest( array( 'var' => 'value' ) );

Add mock $_POST data via $this->mockPostRequest( array( 'var' => 'value' ) );

Mock HTTP request made via wp_remote_request().

Before calling wp_remote_request() run $this->mock_http_request( $url, $data, $fuzzy_match ) to setup the desired return of the next wp_remote_request().

When wp_remote_request() is run, the mocker will check to see if a mock has been added for the URL, if found, it will short-circuit the HTTP request and return early (before any remote connection is made), returning the value of $data. Once the mock is found and returned, it will be removed from the mocker's data. If you wish to mock several consecutive URLs you can call mock_http_request() multiple times. The matcher will always return the first match. So if you wish to mock the same URL more than once, make sure setup the mocks in the order you expect them to be returned.

You can specify a full or partial URL as the $url parameter. If a specifying a partial URL, use $fuzzy_match = true to match the URL part.

php public function test_example_exit() { $this->expectException( LLMS_Unit_Test_Exception_Exit::class ); example_function_that_exits(); }



##### LLMS_Unit_Test_Exception_Redirect

Test methods which call `llms_redirect_and_exit()`:

The exceptions will cause PHP execution to cease. To run additional tests after the exception is encountered add a try/catch block:

## Factories

Test cases which extend the `LLMS_Unit_Test_Case` class may access factories built off the WP Unit Tests Factories: `WP_UnitTest_Factory_For_Post` and `WP_UnitTest_Factory_For_User`

##### Course Post Factory

Access the factory: `$this->factory->course`

Create a course and retrieve the course ID: `$course_id = $this->factory->course->create();`

Create a course and retrieve LLMS_Course object: `$course = $this->factory->course->create_and_get();`

Create a many courses: `$courses = $this->factory->course->create_many( 5 );`

Specify the number of sections, lessons, quizzes, and questions:

##### Membership Post Factory

Access the factory: `$this->factory->membership`

Create a membership and retrieve the membership ID: `$membership_id = $this->factory->membership->create();`

Create a membership and retrieve LLMS_Membership object: `$membership = $this->factory->membership->create_and_get();`

Create a many memberships: `$memberships = $this->factory->membership->create_many( 5 );`

##### Order Post Factory

Access the factory: `$this->factory->order`

Create an order and retrieve the order ID: `$order_id = $this->factory->order->create();`

Create an order and retrieve LLMS_Order object: `$order = $this->factory->order->create_and_get();`

Create a many orders: `$orders = $this->factory->order->create_many( 5 );`

Create an order and record a transaction for it LLMS_Order: `$order = $this->factory->order->create_and_pay();`

##### Student User Factory

Access the factory: `$this->factory->student`

Create a student and retrieve the student ID: `$student_id = $this->factory->student->create();`

Create a student and retrieve LLMS_Student object: `$student = $this->factory->student->create_and_get();`

Create a many students: `$students = $this->factory->student->create_many( 5 );`

Create a student(s) and enroll into a course/membership:

##### Instructor User Factory

Access the factory: `$this->factory->instructor`

Create a instructor and retrieve the instructor ID: `$instructor_id = $this->factory->instructor->create();`

Create a instructor and retrieve LLMS_Instructor object: `$instructor = $this->factory->instructor->create_and_get();`

## Cookies

Test methods and functions that set cookies via `llms_setcookie` using the `LLMS_Tests_Cookies` class.

Access the class: `$this->cookies`.

##### Set a cookie

##### Retrieve set cookie(s)

##### Mock the expected response of llms_setcookie()

Mock a success response:

In the testing suite `llms_setcookie()` will always respond `true` so it's not necessary to call `expect_success()` unless you previously call `expect_error()` in the same test.

Mock an error response:

##### Clear set cookie(s)

Clear all cookies:

Clear a single cookie by name:

All versions of lifterlms-tests with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.0
phpunit/phpunit Version ^7.5 || ^9.5
yoast/phpunit-polyfills Version ^1.0
wp-cli/wp-cli-tests Version ^4.2.9
wp-cli/extension-command Version ^2.1.13
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 lifterlms/lifterlms-tests contains the following files

Loading the files please wait ....