Download the PHP package chqthomas/approval-tests without Composer

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

PHP Approval Tests

A PHP library for approval testing. This approach allows you to verify complex results by comparing them with approved versions, making it ideal for testing outputs that are difficult to assert traditionally (e.g., HTML, JSON, XML, or binary files).

[!WARNING]
This library is still in development. It is not recommended for production use. Many features are still missing, and the API may change.

Table of Contents

Installation

Install the library via Composer:

Basic Usage

Simple Test

Verify a simple string output:

The first time this runs, it generates a .received.txt file. Approve it by renaming it to .approved.txt or use auto-approval (see below).

Structured Data Test

Verify complex data structures like arrays or objects:

Specialized Verifications

The library supports specific formats with dedicated methods:

HTML

Verify HTML content with automatic formatting:

JSON

Verify JSON with pretty-printing and scrubbing:

XML

Verify XML with formatting:

CSV

Verify CSV content:

Binary Files

Verify binary content (e.g., images):

Advanced Features

Tests with Data Providers

Use PHPUnit data providers for parameterized tests:

Verify All Combinations

Test all combinations of inputs:

Configuration

Customize the library’s behavior via the Configuration class:

PHPUnit Bootstrap Configuration

Create a tests/bootstrap.php file to configure the library globally for all your tests:

Then reference it in your phpunit.xml:

Set a Custom Reporter

Change how differences are reported:

Use a Custom Object Formatter

Switch between default and Symfony formatters:

Note: Requires symfony/serializer to be installed for SymfonyObjectFormatter.

Custom Namer

Set a custom namer for file naming:

Auto-Approve Snapshots

Automatically approve new or changed snapshots:

Or use an environment variable:

Scrubbers

Scrubbers normalize content before comparison, handling dynamic data like dates or IDs.

JSON Scrubbing

Scrub sensitive or variable data:

Ignore JSON Members

Remove specific members:

Scrub JSON Members

Replace members with a placeholder:

XML Scrubbing

Custom scrubbing for XML:

Regex Scrubbing

Use regular expressions for generic scrubbing:

Custom Scrubber

Create a custom scrubber for any content:

Maintenance

Cleanup Received Files

Remove redundant .received files:

Detect Orphaned Files

Find .approved files without associated tests:

Reporters

Customize how differences are reported:

CLI Reporter

Default reporter for terminal output:

Diff Reporter

Show differences using a diff format:

Composite Reporter

Combine multiple reporters:

Symfony Integration

Use with Symfony’s DomCrawler for web testing:

Best Practices

  1. Store .approved files in version control.
  2. Use scrubbers for variable data (e.g., dates, IDs).
  3. Regularly clean up .received files.
  4. Check for orphaned .approved files.
  5. Use descriptive test names for clear file naming.

Contributing

Contributions are welcome! To contribute:

  1. Fork the project.
  2. Create a feature branch.
  3. Submit a pull request.

License

MIT License


All versions of approval-tests with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
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 chqthomas/approval-tests contains the following files

Loading the files please wait ....